Closed colemannugent closed 3 years ago
This results in quite a bit of user confusion since one expects hostname verification to be handled by OpenSSL itself rather than by the HTTP library.
Yeah, it's a big mess. OpenSSL itself didn't implement hostname verification at all until quite recently, leaving all users of it to reimplement it poorly themselves (and as it were, I ended up rewriting the hostname verification code used by Ruby itself due to numerous problems).
Anyway, approved! Thanks for the fix.
Per #633 CI is broken (thanks Travis), but I'm going to go ahead and merge this.
Seems like this PR broke jRuby:
@ixti aah, unfortunate. Sorry about that.
Seems like it can at least be worked around with reflection.
jRuby has older version of OpenSSL gem bundled in.
I was suggesting something like:
if ssl_context.respond_to?(:verify_hostname) && ssl_context.verify_hostname
@socket.post_connection_check(host)
end
@tarcieri :+1: Will do so!
I stumbled upon an issue where http.rb wouldn't respect the
verify_hostname
value of the current OpenSSL::SSL::SSLContext.Previously we would unconditionally call post_connection_check, whose only purpose is to verify hostnames, regardless of what
verify_hostname
was set to. This results in quite a bit of user confusion since one expects hostname verification to be handled by OpenSSL itself rather than by the HTTP library.Digging through the blames, it looks like this was never implemented properly. Ruby's Net::HTTP fixed the same issue with this pull in January.
This simple change fixes the issue for me and brings http.rb in line with the other Ruby HTTP libraries.