coalescing: do not try to use a self-signed certificate for coalescing verification purposes

This commit is contained in:
HoneyryderChuck 2021-11-17 21:35:31 +00:00
parent f31b06c150
commit c7d73d09b8
2 changed files with 7 additions and 1 deletions

View File

@ -117,7 +117,8 @@ module HTTPX
def coalescable?(connection)
if @io.protocol == "h2" &&
@origin.scheme == "https" &&
connection.origin.scheme == "https"
connection.origin.scheme == "https" &&
@io.can_verify_peer?
@io.verify_hostname(connection.origin.host)
else
@origin == connection.origin
@ -463,6 +464,7 @@ module HTTPX
transition(:closing)
transition(:closed)
emit(:reset)
@parser.reset if @parser
transition(:idle)
transition(:open)

View File

@ -27,6 +27,10 @@ module HTTPX
super
end
def can_verify_peer?
@ctx.verify_mode == OpenSSL::SSL::VERIFY_PEER
end
def verify_hostname(host)
return false if @ctx.verify_mode == OpenSSL::SSL::VERIFY_NONE
return false if !@io.respond_to?(:peer_cert) || @io.peer_cert.nil?