virustotal-api icon indicating copy to clipboard operation
virustotal-api copied to clipboard

Using the api from behind a SSL proxy

Open tessem opened this issue 4 years ago • 6 comments

How to use from behind a proxy server.

print(json.dumps(response, sort_keys=False, indent=4)) { "error": "HTTPSConnectionPool(host='www.virustotal.com', port=443): Max retries exceeded with url: /vtapi/v2/file/report?apikey=xxxcutxxx&resource=xxxcutxxx (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)')))" }

tessem avatar Oct 05 '20 10:10 tessem

Hey @tessem, I don't believe this is an issue with the library. Your proxy server's SSL certificate is not able to be validated by Python's certificate bundle. This is a common issue in Python when using requests/urllib against endpoints that have certificates signed by internal certificate authorities.

ghost avatar Oct 05 '20 17:10 ghost

from __future__ import print_function
import json
import hashlib
from virus_total_apis import PublicApi as VirusTotalPublicApi

API_KEY = 'Sign-Up for API Key at virustotal.com'

EICAR = "X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*".encode('utf-8')
EICAR_MD5 = hashlib.md5(EICAR).hexdigest()

proxies = {
  'http': 'http://10.10.1.10:3128',
  'https': 'http://10.10.1.10:1080',
}
vt = VirusTotalPublicApi(API_KEY, proxies=proxies)

response = vt.get_file_report(EICAR_MD5)
print(json.dumps(response, sort_keys=False, indent=4))

blacktop avatar Oct 05 '20 17:10 blacktop

But @KadenLNelson is correct, if after you appy your proxy settings if it is still not working its because we don't support disabling ssl verification, but we could if need be.

@KadenLNelson it would just require adding support to pass through to requests' verify=False flag.

blacktop avatar Oct 05 '20 17:10 blacktop

Or you could make sure the system you are running on can trust/verify your proxy's cert as well.

blacktop avatar Oct 05 '20 17:10 blacktop

Both

verify=False

and

verify='SomeCertificates.pem'

would work fine.

tessem avatar Oct 06 '20 07:10 tessem

I would also appreciate a verify=False flag.

idev avatar Dec 08 '20 13:12 idev