File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -1001,7 +1001,7 @@ def ssl connection
1001
1001
connection . verify_depth = @verify_depth
1002
1002
connection . verify_mode = @verify_mode
1003
1003
connection . verify_hostname = @verify_hostname if
1004
- @verify_hostname && connection . respond_to? ( :verify_hostname= )
1004
+ @verify_hostname != nil && connection . respond_to? ( :verify_hostname= )
1005
1005
1006
1006
if OpenSSL ::SSL ::VERIFY_PEER == OpenSSL ::SSL ::VERIFY_NONE and
1007
1007
not Object . const_defined? ( :I_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG ) then
@@ -1111,7 +1111,7 @@ def verify_mode= verify_mode
1111
1111
end
1112
1112
1113
1113
##
1114
- # Sets the HTTPS verify_hostname. Defaults to false.
1114
+ # Sets the HTTPS verify_hostname.
1115
1115
1116
1116
def verify_hostname = verify_hostname
1117
1117
@verify_hostname = verify_hostname
@@ -1131,4 +1131,3 @@ def verify_callback= callback
1131
1131
1132
1132
require_relative 'persistent/connection'
1133
1133
require_relative 'persistent/pool'
1134
-
Original file line number Diff line number Diff line change @@ -1343,7 +1343,7 @@ def test_ssl_verify_mode
1343
1343
assert_equal OpenSSL ::SSL ::VERIFY_NONE , c . verify_mode
1344
1344
end
1345
1345
1346
- def test_ssl_verify_hostname
1346
+ def test_ssl_enable_verify_hostname
1347
1347
skip 'OpenSSL is missing' unless HAVE_OPENSSL
1348
1348
1349
1349
@http . verify_hostname = true
@@ -1358,6 +1358,22 @@ def test_ssl_verify_hostname
1358
1358
assert c . verify_hostname
1359
1359
end
1360
1360
1361
+ def test_ssl_disable_verify_hostname
1362
+ skip 'OpenSSL is missing' unless HAVE_OPENSSL
1363
+
1364
+ @http . verify_hostname = false
1365
+ c = Net ::HTTP . new 'localhost' , 80
1366
+
1367
+ skip 'net/http doesn\'t provide verify_hostname= method' unless
1368
+ c . respond_to? ( :verify_hostname= )
1369
+
1370
+ @http . ssl c
1371
+
1372
+ assert c . use_ssl?
1373
+ assert c . verify_hostname == false
1374
+ end
1375
+
1376
+
1361
1377
def test_ssl_warning
1362
1378
skip 'OpenSSL is missing' unless HAVE_OPENSSL
1363
1379
@@ -1474,4 +1490,3 @@ def test_connection_pool_after_fork
1474
1490
end
1475
1491
end
1476
1492
end
1477
-
You can’t perform that action at this time.
0 commit comments