File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -270,6 +270,11 @@ def self.detect_idle_timeout uri, max = 10
270270
271271 attr_reader :ciphers
272272
273+ ##
274+ # Extra certificates to be added to the certificate chain
275+
276+ attr_reader :extra_chain_cert
277+
273278 ##
274279 # Sends debug_output to this IO via Net::HTTP#set_debug_output.
275280 #
@@ -574,6 +579,14 @@ def ciphers= ciphers
574579 reconnect_ssl
575580 end
576581
582+ ##
583+ # Extra certificates to be added to the certificate chain
584+ def extra_chain_cert = extra_chain_cert
585+ @extra_chain_cert = extra_chain_cert
586+
587+ reconnect_ssl
588+ end
589+
577590 ##
578591 # Creates a new connection for +uri+
579592
@@ -1023,6 +1036,10 @@ def ssl connection
10231036 connection . key = @private_key
10241037 end
10251038
1039+ if @extra_chain_cert
1040+ connection . extra_chain_cert = @extra_chain_cert
1041+ end
1042+
10261043 connection . cert_store = if @cert_store then
10271044 @cert_store
10281045 else
Original file line number Diff line number Diff line change @@ -247,6 +247,13 @@ def test_ciphers_equals
247247 assert_equal 1 , @http . ssl_generation
248248 end
249249
250+ def test_extra_chain_cert_equals
251+ @http . extra_chain_cert = :extra_chain_cert
252+
253+ assert_equal :extra_chain_cert , @http . extra_chain_cert
254+ assert_equal 1 , @http . ssl_generation
255+ end
256+
250257 def test_connection_for
251258 @http . open_timeout = 123
252259 @http . read_timeout = 321
@@ -1342,6 +1349,18 @@ def test_ssl_verify_mode
13421349 assert_equal OpenSSL ::SSL ::VERIFY_NONE , c . verify_mode
13431350 end
13441351
1352+ def test_ssl_extra_chain_cert
1353+ skip 'OpenSSL is missing' unless HAVE_OPENSSL
1354+
1355+ @http . extra_chain_cert = :extra_chain_cert
1356+ c = Net ::HTTP . new 'localhost' , 80
1357+
1358+ @http . ssl c
1359+
1360+ assert c . use_ssl?
1361+ assert_equal :extra_chain_cert , c . extra_chain_cert
1362+ end
1363+
13451364 def test_ssl_warning
13461365 skip 'OpenSSL is missing' unless HAVE_OPENSSL
13471366
You can’t perform that action at this time.
0 commit comments