net-http-persistent 4.0.2 → 4.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9123e98741595dbcc1c9a9713ecdcfb517597dc52791dc546bd868c31cbe88d0
4
- data.tar.gz: 462f4ae1dd63c8776ac18e3eab2b8e4c43e65d906722086a670d5ae3b764eb2b
3
+ metadata.gz: dda1829232ea53f61dd44b4added8e65777661bb9c2bb8f4c49014c7dbbe3d1d
4
+ data.tar.gz: 9321f0aad6dbc328d2612212321e9f2daa8cad2330f677208c55089676f666e7
5
5
  SHA512:
6
- metadata.gz: 45e3ea77d23e8c9829bba490c61546b71a221194cf8106bbb32ad746408283df04923649aef952d7317f06475a0a5466b19376c7a38e8b62490d65f24b6031cf
7
- data.tar.gz: e46564075c2d655e258c5fd9ff3c45843b48c5bd6d8c5f80fe84450a36e7ac5811d0f97b5e8223277c2b607e7259df70e1e331c372e12a4bd33efec0e555e743
6
+ metadata.gz: 9ca608a9a2f899b0ac3636d848f4581085fae57eec74527ed457e21a6c1988d909123cd4d4e102ab77d53a3839e9778adc140ecdff9d57d5f1dcbcd2c2d69c5c
7
+ data.tar.gz: 03622a828eea0b5266511a39afc8bafdccf41d1e7e572cf04e0e23548104307d857b33bdaa387ed12ef46f8fd890762a8d39fa3ac9a4e2ca7d70026cd9bfd1b5
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 4.0.2 / 2024-09-09
2
+
3
+ Bug fixes:
4
+
5
+ * Handle Net::HTTP#verify_hostname was added in Ruby 3.0 or later. #120
6
+
1
7
  === 4.0.2 / 2023-03-29
2
8
 
3
9
  Bug fixes:
@@ -73,6 +73,8 @@ autoload :OpenSSL, 'openssl'
73
73
  # #verify_callback :: For server certificate verification
74
74
  # #verify_depth :: Depth of certificate verification
75
75
  # #verify_mode :: How connections should be verified
76
+ # #verify_hostname :: Use hostname verification for server certificate
77
+ # during the handshake
76
78
  #
77
79
  # == Proxies
78
80
  #
@@ -179,7 +181,7 @@ class Net::HTTP::Persistent
179
181
  ##
180
182
  # The version of Net::HTTP::Persistent you are using
181
183
 
182
- VERSION = '4.0.2'
184
+ VERSION = '4.0.3'
183
185
 
184
186
  ##
185
187
  # Error class for errors raised by Net::HTTP::Persistent. Various
@@ -454,6 +456,21 @@ class Net::HTTP::Persistent
454
456
 
455
457
  attr_reader :verify_mode
456
458
 
459
+ ##
460
+ # HTTPS verify_hostname.
461
+ #
462
+ # If a client sets this to true and enables SNI with SSLSocket#hostname=,
463
+ # the hostname verification on the server certificate is performed
464
+ # automatically during the handshake using
465
+ # OpenSSL::SSL.verify_certificate_identity().
466
+ #
467
+ # You can set +verify_hostname+ as true to use hostname verification
468
+ # during the handshake.
469
+ #
470
+ # NOTE: This works with Ruby > 3.0.
471
+
472
+ attr_reader :verify_hostname
473
+
457
474
  ##
458
475
  # Creates a new Net::HTTP::Persistent.
459
476
  #
@@ -513,6 +530,7 @@ class Net::HTTP::Persistent
513
530
  @verify_callback = nil
514
531
  @verify_depth = nil
515
532
  @verify_mode = nil
533
+ @verify_hostname = nil
516
534
  @cert_store = nil
517
535
 
518
536
  @generation = 0 # incremented when proxy URI changes
@@ -612,13 +630,23 @@ class Net::HTTP::Persistent
612
630
 
613
631
  return yield connection
614
632
  rescue Errno::ECONNREFUSED
615
- address = http.proxy_address || http.address
616
- port = http.proxy_port || http.port
633
+ if http.proxy?
634
+ address = http.proxy_address
635
+ port = http.proxy_port
636
+ else
637
+ address = http.address
638
+ port = http.port
639
+ end
617
640
 
618
641
  raise Error, "connection refused: #{address}:#{port}"
619
642
  rescue Errno::EHOSTDOWN
620
- address = http.proxy_address || http.address
621
- port = http.proxy_port || http.port
643
+ if http.proxy?
644
+ address = http.proxy_address
645
+ port = http.proxy_port
646
+ else
647
+ address = http.address
648
+ port = http.port
649
+ end
622
650
 
623
651
  raise Error, "host down: #{address}:#{port}"
624
652
  ensure
@@ -970,8 +998,10 @@ class Net::HTTP::Persistent
970
998
  connection.min_version = @min_version if @min_version
971
999
  connection.max_version = @max_version if @max_version
972
1000
 
973
- connection.verify_depth = @verify_depth
974
- connection.verify_mode = @verify_mode
1001
+ connection.verify_depth = @verify_depth
1002
+ connection.verify_mode = @verify_mode
1003
+ connection.verify_hostname = @verify_hostname if
1004
+ @verify_hostname && connection.respond_to?(:verify_hostname=)
975
1005
 
976
1006
  if OpenSSL::SSL::VERIFY_PEER == OpenSSL::SSL::VERIFY_NONE and
977
1007
  not Object.const_defined?(:I_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG) then
@@ -1080,6 +1110,15 @@ application:
1080
1110
  reconnect_ssl
1081
1111
  end
1082
1112
 
1113
+ ##
1114
+ # Sets the HTTPS verify_hostname. Defaults to false.
1115
+
1116
+ def verify_hostname= verify_hostname
1117
+ @verify_hostname = verify_hostname
1118
+
1119
+ reconnect_ssl
1120
+ end
1121
+
1083
1122
  ##
1084
1123
  # SSL verification callback.
1085
1124
 
@@ -116,6 +116,9 @@ class TestNetHttpPersistent < Minitest::Test
116
116
  end
117
117
  def proxy_port
118
118
  end
119
+ def proxy?
120
+ false
121
+ end
119
122
  end
120
123
 
121
124
  def basic_connection
@@ -1256,6 +1259,7 @@ class TestNetHttpPersistent < Minitest::Test
1256
1259
  assert_equal OpenSSL::SSL::VERIFY_PEER, c.verify_mode
1257
1260
  assert_kind_of OpenSSL::X509::Store, c.cert_store
1258
1261
  assert_nil c.verify_callback
1262
+ assert_nil c.verify_hostname if c.respond_to?(:verify_hostname)
1259
1263
  end
1260
1264
 
1261
1265
  def test_ssl_ca_file
@@ -1339,6 +1343,21 @@ class TestNetHttpPersistent < Minitest::Test
1339
1343
  assert_equal OpenSSL::SSL::VERIFY_NONE, c.verify_mode
1340
1344
  end
1341
1345
 
1346
+ def test_ssl_verify_hostname
1347
+ skip 'OpenSSL is missing' unless HAVE_OPENSSL
1348
+
1349
+ @http.verify_hostname = true
1350
+ c = Net::HTTP.new 'localhost', 80
1351
+
1352
+ skip 'net/http doesn\'t provide verify_hostname= method' unless
1353
+ c.respond_to?(:verify_hostname=)
1354
+
1355
+ @http.ssl c
1356
+
1357
+ assert c.use_ssl?
1358
+ assert c.verify_hostname
1359
+ end
1360
+
1342
1361
  def test_ssl_warning
1343
1362
  skip 'OpenSSL is missing' unless HAVE_OPENSSL
1344
1363
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-http-persistent
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Hodel
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-03-29 00:00:00.000000000 Z
10
+ date: 2024-09-09 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: connection_pool
@@ -63,7 +62,6 @@ licenses:
63
62
  - MIT
64
63
  metadata:
65
64
  homepage_uri: https://github.com/drbrain/net-http-persistent
66
- post_install_message:
67
65
  rdoc_options:
68
66
  - "--main"
69
67
  - README.rdoc
@@ -80,8 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
78
  - !ruby/object:Gem::Version
81
79
  version: '0'
82
80
  requirements: []
83
- rubygems_version: 3.0.3.1
84
- signing_key:
81
+ rubygems_version: 3.6.0.dev
85
82
  specification_version: 4
86
83
  summary: Manages persistent connections using Net::HTTP including a thread pool for
87
84
  connecting to multiple hosts