diff options
author | NARUSE, Yui <naruse@airemix.jp> | 2019-12-09 20:19:11 +0900 |
---|---|---|
committer | NARUSE, Yui <naruse@airemix.jp> | 2019-12-09 20:21:49 +0900 |
commit | 54072e329cab7207fba133caba4fc12b45add8f9 (patch) | |
tree | 89cc3dca25a16017330c81cf5dc13243894c2313 /test/net | |
parent | 194327942690a7997c7b48d34cc105c6ec8b8d40 (diff) |
Add ipaddr optional parameter to Net::HTTP#start
to replace the address for TCP/IP connection [Feature #5180]
There're 3 layers of hostname:
* host address for TCP/IP
* TLS server name
* HTTP Host header value
To test DNS round robin or check server certificate from server local,
people sometimes want to connect server with given IP address but keep
TLS server name and HTTP Host header value.
closes [Feature #15215]
closes https://github.com/ruby/ruby/pull/1893
closes https://github.com/ruby/ruby/pull/1977
Diffstat (limited to 'test/net')
-rw-r--r-- | test/net/http/test_https.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/net/http/test_https.rb b/test/net/http/test_https.rb index c1d486470a..9058387070 100644 --- a/test/net/http/test_https.rb +++ b/test/net/http/test_https.rb @@ -50,6 +50,37 @@ class TestNetHTTPS < Test::Unit::TestCase skip $! end + def test_get_SNI + http = Net::HTTP.new("localhost", config("port")) + http.ipaddr = config('host') + http.use_ssl = true + http.cert_store = TEST_STORE + certs = [] + http.verify_callback = Proc.new do |preverify_ok, store_ctx| + certs << store_ctx.current_cert + preverify_ok + end + http.request_get("/") {|res| + assert_equal($test_net_http_data, res.body) + } + assert_equal(CA_CERT.to_der, certs[0].to_der) + assert_equal(SERVER_CERT.to_der, certs[1].to_der) + end + + def test_get_SNI_failure + http = Net::HTTP.new("invalid_servername", config("port")) + http.ipaddr = config('host') + http.use_ssl = true + http.cert_store = TEST_STORE + certs = [] + http.verify_callback = Proc.new do |preverify_ok, store_ctx| + certs << store_ctx.current_cert + preverify_ok + end + @log_tester = lambda {|_| } + assert_raise(OpenSSL::SSL::SSLError){ http.start } + end + def test_post http = Net::HTTP.new("localhost", config("port")) http.use_ssl = true |