1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/net-smtp] TLS should not check the host name by default.

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.

https://github.com/ruby/net-smtp/commit/bde75a15b5
This commit is contained in:
TOMITA Masahiro 2020-07-15 00:50:16 +09:00 committed by Hiroshi SHIBATA
parent cdb85142f9
commit 888e04ae05
2 changed files with 4 additions and 2 deletions

View file

@ -583,7 +583,7 @@ module Net
logging "TLS connection started"
s.sync_close = true
ssl_socket_connect(s, @open_timeout)
if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
if @ssl_context.verify_mode && @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
s.post_connection_check(@address)
end
verified = true

View file

@ -53,8 +53,10 @@ module Net
end
}
ssl_context = OpenSSL::SSL::SSLContext.new
ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER
connection = MySMTP.new('localhost', 25)
connection.enable_starttls_auto
connection.enable_starttls_auto(ssl_context)
connection.fake_tcp = tcp_socket
connection.fake_ssl = ssl_socket