TLS should not check the host name by default.#6
Conversation
In tlsconnect(), the host name is checked when @ssl_context.verify_mode is not OpenSSL::SSL::VERIFY_NONE, but the verify_mode of @ssl_context generated by default is nil.
aeadb49 to
bde75a1
Compare
|
Good catch. I would have expected |
|
I prefer secure default and easy to disable. For example, require 'open-uri'
URI.open('https://expired.badssl.com/', ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE, &:read) |
Agreed. ruby/openssl#386 |
|
The change in this pull request is correct as it currently trying to verify CN/SAN without checking the signature, which is completely useless. Aside from that, net/smtp should have a better default. In fact, other net/* libraries do verify server certificate by default. (And that's why net/* libraries all have different interfaces for SSL/TLS parameters, which I think should be unified at some time, but that's yet another topic.
[*] SSLContext#set_params is a utility method to set sane default parameters for public internet services (which can be overridden by the Hash passed to the method). |
|
That's right. I also think net/smtp should be able to connect securely by default. |
knu
left a comment
There was a problem hiding this comment.
I agree that calling post_connection_check() does not make sense when verify_mode is not set.
In tlsconnect(), the host name is checked when @ssl_context.verify_mode is not OpenSSL::SSL::VERIFY_NONE, but the verify_mode of @ssl_context generated by default is nil.