Skip to content

Auto-reconnection does not work on SNI #62

Open
@dissolve

Description

@dissolve

When I establish a connection to a site that uses SNI (and the key returned by the request is not usable) and then try to re-use that connection after 300 seconds, I get an error that the certificate does not match the hostname. Watching from wireshark confirmed, that on the initial request the certificate for *.shanske.com is returned, however after 5 minutes, the certificate for weneca.com is returned (the server's main key, same as would be returned without SNI). So it would seem that the reconnection is not including the hostname.

To reproduce

require 'net/http/persistent'
http = Net::HTTP::Persistent.new
uri = URI 'https://david.shanske.com'
response = http.request uri
sleep 310 
response = http.request uri
OpenSSL::SSL::SSLError: hostname "david.shanske.com" does not match the server certificate
        from /usr/lib64/ruby/2.1.0/openssl/ssl.rb:139:in `post_connection_check'
        from /usr/lib64/ruby/2.1.0/net/http.rb:922:in `connect'
        from /usr/lib64/ruby/2.1.0/net/http.rb:863:in `do_start'
        from /usr/lib64/ruby/2.1.0/net/http.rb:858:in `start'
        from /usr/lib64/ruby/gems/2.1.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:700:in `start'
        from /usr/lib64/ruby/gems/2.1.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:965:in `reset'
        from /usr/lib64/ruby/gems/2.1.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:628:in `connection_for'
        from /usr/lib64/ruby/gems/2.1.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:994:in `request'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions