Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
OpenSSL::SSL::SSLSocket#post_connection_check
ssl.post_connection_check(hostname) → true
ext/openssl/lib/openssl/ssl.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/ext/openssl/lib/openssl/ssl.rb, line 397
def post_connection_check(hostname)
if peer_cert.nil?
msg = "Peer verification enabled, but no certificate received."
if using_anon_cipher?
msg += " Anonymous cipher suite #{cipher[0]} was negotiated. " \
"Anonymous suites must be disabled to use peer verification."
end
raise SSLError, msg
end
unless OpenSSL::SSL.verify_certificate_identity(peer_cert, hostname)
raise SSLError, "hostname \"#{hostname}\" does not match the server certificate"
end
return true
end
Perform hostname verification following RFC 6125.
This method MUST be called after calling connect to ensure that the hostname of a remote peer has been verified.