【发布时间】:2018-09-22 01:07:40
【问题描述】:
我使用的是 python 3.6.5 和 Windows 10。我需要获取服务器选择的 TLS 版本(即将用于其余握手的版本,而不是客户端提供的版本)。我这样做了:
import socket, ssl
context = context = ssl.create_default_context()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
domain = 'google.com'
sslSocket = context.wrap_socket(s, server_hostname = domain)
sslSocket.connect((domain, 443))
print('the selected version by the server: ', sslSocket.cipher()[1])
print("success")
sslSocket.close()
但是输出是:
the selected version by the server: TLSv1/SSLv3
success
我需要准确的版本。即,在与google.com 的连接中,它是TLS 1.2,如浏览器所示。如何在我的代码中获得准确的版本?
【问题讨论】:
标签: python sockets ssl tls1.2 pyopenssl