问题
I can connect fine with Python to any external https site without this error: SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))
But I have a local webserver on my laptop with a self-signed certificate that works fine in itself but Python generates an _ssl.c:1108 error when I try to connect to it.
Any ideas?
回答1:
The python client does not have access and trust the CA certificate that signed the web server certificate. In your case that is the self-signed web server certificate.
To get the python client working, you can do the following:
- disable certificate verification. That is not a good idea but I guess is ok for a quick test. The emphasis is on "it is not recommended".
- Download the self-signed certificate and make it accessible to the python client and specify it as trusted CA certificate.
- Download and install a certificate from well known CAs such as LetsEncrypt (free) or commercial CAs. This is the recommended approach.
You could go into depth on the items mentioned herein and get a conceptual understanding how TLS operates.
EDIT 1: You could also get a free certificate from LetsEncrypt CA
. Or you could get a free test certificate from most of the commercial CAs
like DigiCert etc. See this link for getting and installing a free test certificate signed by a DigiCert test CA.
See this for details on python client configuration for TLS.
来源:https://stackoverflow.com/questions/61221803/only-on-local-machine-ssl-certificate-verify-failed-ssl-c1108-error