mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-07 00:05:02 -04:00
allow passing custom hostname to tls options for SNI
this effectively allows one to perform TLS negotiation with a reverse-proxy while passing a different host. This host can also be passed directly in the "host" header while the uri can contain the IP
This commit is contained in:
parent
0c646ced85
commit
dd28a39eef
@ -15,8 +15,10 @@ module HTTPX
|
||||
def initialize(_, _, options)
|
||||
@ctx = OpenSSL::SSL::SSLContext.new
|
||||
ctx_options = TLS_OPTIONS.merge(options.ssl)
|
||||
@tls_hostname = ctx_options.delete(:hostname)
|
||||
@ctx.set_params(ctx_options) unless ctx_options.empty?
|
||||
super
|
||||
@tls_hostname ||= @hostname
|
||||
@state = :negotiated if @keep_open
|
||||
end
|
||||
|
||||
@ -59,11 +61,11 @@ module HTTPX
|
||||
|
||||
unless @io.is_a?(OpenSSL::SSL::SSLSocket)
|
||||
@io = OpenSSL::SSL::SSLSocket.new(@io, @ctx)
|
||||
@io.hostname = @hostname
|
||||
@io.hostname = @tls_hostname
|
||||
@io.sync_close = true
|
||||
end
|
||||
@io.connect_nonblock
|
||||
@io.post_connection_check(@hostname) if @ctx.verify_mode != OpenSSL::SSL::VERIFY_NONE
|
||||
@io.post_connection_check(@tls_hostname) if @ctx.verify_mode != OpenSSL::SSL::VERIFY_NONE
|
||||
transition(:negotiated)
|
||||
rescue ::IO::WaitReadable
|
||||
@interests = :r
|
||||
|
Loading…
x
Reference in New Issue
Block a user