[英]_ssl.c:351: error:140B0009:SSL routines:SSL_CTX_use_PrivateKey_file:PEM lib
I want to connect to a web server that has a self-signed certificate, with Requests: 我想使用请求连接到具有自签名证书的Web服务器:
try:
requests.get(url, cert=PATH_CERTIFICATE)
except requests.exceptions.ConnectionError as e:
logger.info(e)
But it fails with the following: 但是由于以下原因而失败:
[Errno 336265225] _ssl.c:351: error:140B0009:SSL routines:SSL_CTX_use_PrivateKey_file:PEM lib
[Errno 336265225] _ssl.c:351:错误:140B0009:SSL例程:SSL_CTX_use_PrivateKey_file:PEM库
I got this certificate by running this command: 我通过运行以下命令获得了此证书:
openssl s_client -showcerts -ssl3 -connect <hostname:port>
使用verify
关键字,而不是cert
:
requests.get(url, verify=PATH_CERTIFICATE)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.