0

I have my python script similar to below, Scripts works fine in my personal laptop.

import plivo
import sys

auth_id = "XXXXXX"
auth_token = "YYYYYYYYYYYY"
test = plivo.RestClient(auth_id, auth_token)

message_created = test.messages.create(
    src='ZZZZZZ',
    dst='+NNNNN',
    text='Testing!!'
) 

However while running the script in our organization PC's its throwing error

raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='api.plivo.com', port=443): **Max retries exceeded with url**: /v1/Account/SXXXXXYW/Message/ (Cau
sed by SSLError(SSLError(1, u'[SSL: **CERTIFICATE_VERIFY_FAILED**] certificate verify failed (_ssl.c:590)'),))

I tried to add ssl._create_default_https_context = ssl._create_unverified_context and PYTHONHTTPSVERIFY=0 but unfortunately nothing works for me. Can anyone one help me how to resolve the error?

Naveen.S
  • 730
  • 5
  • 21

1 Answers1

0

Try the solution from https://github.com/locustio/locust/issues/417

How to get rid from “SSL: CERTIFICATE_VERIFY_FAILED” Error

On Windows, Python does not look at the system certificate, it uses its own located at ?\lib\site-packages\certifi\cacert.pem.

The solution to your problem:

  1. download the domain validation certificate as *.crt or *pem file
  2. open the file in editor and copy it's content to clipboard
  3. find your cacert.pem location: from requests.utils import DEFAULT_CA_BUNDLE_PATH; print(DEFAULT_CA_BUNDLE_PATH)
  4. edit the cacert.pem file and paste your domain validation certificate at the end of the file.
  5. Save the file and enjoy requests!
leiyc
  • 903
  • 11
  • 23