0

我正在尝试用 Python 连接到我的一台服务器。

当我发出以下命令时,在我的 Windows 10 系统上:

openssl s_client -connect host_ip:443

结果是:

---
SSL handshake has read 858 bytes and written 494 bytes
---
New, TLSv1/SSLv3, Cipher is RC4-SHA
Server public key is 1024 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.1
    Cipher    : RC4-SHA

来到 python,我尝试设置 SSL 上下文和密码:

ssl_context = ssl.create_default_context()

### The Following Changes Worked setting up the cipher ####

ciphers = ssl._DEFAULT_CIPHERS
# print (ciphers)
ciphers = re.sub(r":!RC4", "", ciphers)
# print(ciphers)
ciphers = ciphers + ":RC4-SHA"
ssl_context.set_ciphers(ciphers)

######################################################
ssl_context.options &= ~ssl.OP_NO_SSLv3  # I need to connect to a old server. 
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE    
.
.
.

但是在建立连接时出现错误:

[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1108)



    

系统版本:

> openssl version
WARNING: can't open config file: /z/extlib/_openssl__/ssl/openssl.cnf
OpenSSL 1.0.2o  27 Mar 2018

> python --version
Python 3.8.3

> pip show pyOpenSSL
Name: pyOpenSSL
Version: 19.1.0
4

0 回答 0