简体   繁体   中英

Python - SSL: CERTIFICATE_VERIFY_FAILED

I have a python script that uses the VirusTotal API. It has been working with no problems, but all of a sudden when I run the script I am getting the following error:

 urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> 

I believe it may be our web proxy that is causing the issue. Is there a way to prevent it from verifying the cert? Here is the portion of the code that uses the API:

json_out = []
url = "https://www.virustotal.com/vtapi/v2/file/report"

parameters = {"resource": my_list,
              "apikey": "<MY API KEY>"}

data = urllib.urlencode(parameters)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
json_out.append (response.read())

I believe it may be our web proxy that is causing the issue. Is there a way to prevent it from verifying the cert?

If you assume that a SSL intercepting proxy is denying the connection then you have to fix the problem at the proxy, ie there is no way to instruct the proxy to not check the certificate from your application.

If instead you assume that there is a SSL intercepting proxy and thus the certificate you receive is not signed by a CA you trust then you should get the CA of the proxy and trust it in your application (see cafile parameter in the documentation ). Disabling validation is almost never the right way. Instead fix it so that validation works.

There are two possibilities,

  1. You are using a self-signed certificate. Browsers don not trust on such certificate, so be sure that you are using CA-signed trusted certificate.
  2. If you are using CA-signed trusted the certificate that you should have to check for install CA chain certificates (Root and Intermediate certificate).

You can refer this article, it may help you. - https://access.redhat.com/articles/2039753

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM