Skip to content

Commit 1e3b0fa

Browse files
author
Pavel Pulec
committed
parameters for SSL and insecure certificate
Signed-off-by: Pavel Pulec <[email protected]>
1 parent 0b1a016 commit 1e3b0fa

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Diff for: check_haproxy.rb

+13-5
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44
require 'open-uri'
55
require 'ostruct'
66
require 'csv'
7-
require 'openssl'
87

98
OK = 0
109
WARNING = 1
1110
CRITICAL = 2
1211
UNKNOWN = 3
1312

14-
# allows https with invalid certificate on ruby 1.8+
15-
#
16-
# src: also://snippets.aktagon.com/snippets/370-hack-for-using-openuri-with-ssl
17-
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
1813

1914
status = ['OK', 'WARN', 'CRIT', 'UNKN']
2015

@@ -59,6 +54,19 @@
5954
options.critical = v
6055
end
6156

57+
opts.on( '-s', '--ssl', 'Enable TLS/SSL' ) do
58+
require 'openssl'
59+
end
60+
61+
opts.on( '-k', '--insecure', 'Allow insecure TLS/SSL connections' ) do
62+
require 'openssl'
63+
64+
# allows https with invalid certificate on ruby 1.8+
65+
#
66+
# src: also://snippets.aktagon.com/snippets/370-hack-for-using-openuri-with-ssl
67+
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
68+
end
69+
6270
opts.on( '-h', '--help', 'Display this screen' ) do
6371
puts opts
6472
exit 3

0 commit comments

Comments
 (0)