我想连接到具有自签名证书的Web服务器,其中包含Requests:
try:
requests.get(url, cert=PATH_CERTIFICATE)
except requests.exceptions.ConnectionError as e:
logger.info(e)
但它失败了以下内容:
[Errno 336265225] _ssl.c:351:错误:140B0009:SSL例程:SSL_CTX_use_PrivateKey_file:PEM lib
我通过运行此命令获得此证书:
openssl s_client -showcerts -ssl3 -connect <hostname:port>
答案 0 :(得分:0)
使用verify
关键字代替cert
:
requests.get(url, verify=PATH_CERTIFICATE)