Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid use of IP addresses in SNI #83

Merged
merged 1 commit into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions test/webrick/test_httpproxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def test_connect
# 3. ------- GET or POST ---------->
#
key = TEST_KEY_RSA2048
cert = make_certificate(key, "127.0.0.1")
cert = make_certificate(key, "localhost")
s_config = {
:SSLEnable =>true,
:ServerName => "localhost",
Expand All @@ -300,7 +300,7 @@ def test_connect
res.body = "SSL #{req.request_method} #{req.path} #{req.body}"
}
TestWEBrick.start_httpproxy(config){|server, addr, port, log|
http = Net::HTTP.new("127.0.0.1", s_port, addr, port)
http = Net::HTTP.new("localhost", s_port, addr, port)
http.use_ssl = true
http.verify_callback = Proc.new do |preverify_ok, store_ctx|
store_ctx.current_cert.to_der == cert.to_der
Expand Down Expand Up @@ -398,7 +398,7 @@ def test_upstream_proxy
# 3. ---------- GET or POST -------------->
#
key = TEST_KEY_RSA2048
cert = make_certificate(key, "127.0.0.1")
cert = make_certificate(key, "localhost")
s_config = {
:SSLEnable =>true,
:ServerName => "localhost",
Expand All @@ -409,7 +409,7 @@ def test_upstream_proxy
s_server.mount_proc("/"){|req2, res|
res.body = "SSL #{req2.request_method} #{req2.path} #{req2.body}"
}
http = Net::HTTP.new("127.0.0.1", s_port, addr, port, up_log.call + log.call + s_log.call)
http = Net::HTTP.new("localhost", s_port, addr, port, up_log.call + log.call + s_log.call)
http.use_ssl = true
http.verify_callback = Proc.new do |preverify_ok, store_ctx|
store_ctx.current_cert.to_der == cert.to_der
Expand Down
5 changes: 5 additions & 0 deletions test/webrick/test_https.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ def empty_log.<<(str)
class HTTPSNITest < ::Net::HTTP
attr_accessor :sni_hostname

def connect
@address = 'localhost' if @address == '127.0.0.1'
super
end

def ssl_socket_connect(s, timeout)
s.hostname = sni_hostname
super
Expand Down