Python SSL CERTIFICATE_VERIFY_FAILED

2019-09-10 08:17发布

问题:

I'm using the following code to interact with a Magento webstore using the XMLRPC api. Magento API Python XMLRPC

Everything was working ok until we made a change on our web server to SSL

Now I'm getting the following error.

ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)

I'm not sure why the certificate is failing as we have an EV certificate and all browsers are showing this as ok.

My connection string is:

How can I resolve this / over-ride the code

I'm fairly new to Python so please go easy :o)

magento = MagentoAPI("www.website.co.uk", 443, "myUsername", "myPassword", "/api/xmlrpc", True)

回答1:

Python, or better the OpenSSL library it is using, can not verify the validity of the certificate of the server. There are many possible reasons: bad configuration, missing intermediate or CA certificate, wrong CN...

A first step could be to go to this site and let it test the SSL/TLS capabilities of the server: https://www.ssllabs.com/ssltest/

It will give you hints on how to solve problems as well.