Skip to content
Merged
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
10 changes: 8 additions & 2 deletions lib/em-http/http_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def ssl_verify_peer(cert_string)
rescue OpenSSL::X509::StoreError => e
raise e unless e.message == 'cert already in hash table'
end
else
raise OpenSSL::SSL::SSLError.new(%(unable to verify the server certificate for "#{sni_hostname}"))
end

true
Expand All @@ -68,8 +70,8 @@ def ssl_handshake_completed
end

unless certificate_store.verify(@last_seen_cert) &&
OpenSSL::SSL.verify_certificate_identity(@last_seen_cert, host)
raise OpenSSL::SSL::SSLError.new(%(host "#{host}" does not match the server certificate))
OpenSSL::SSL.verify_certificate_identity(@last_seen_cert, sni_hostname)
raise OpenSSL::SSL::SSLError.new(%(host "#{sni_hostname}" does not match the server certificate))
else
true
end
Expand All @@ -83,6 +85,10 @@ def host
parent.connopts.host
end

def sni_hostname
parent.connopts.tls[:sni_hostname]
end

def certificate_store
@certificate_store ||= begin
store = OpenSSL::X509::Store.new
Expand Down