简体   繁体   English

SSL:CERTIFICATE_VERIFY_FAILED]证书从python脚本生成SMS时验证失败

[英]SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed while generating SMS from python script

I have my python script similar to below, Scripts works fine in my personal laptop. 我的python脚本类似于以下内容,该脚本在我的个人笔记本电脑上工作正常。

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 但是,在组织PC中运行脚本时,其抛出错误

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. 我试图添加ssl._create_default_https_context = ssl._create_unverified_context和PYTHONHTTPSVERIFY = 0,但不幸的是,没有任何内容适合我。 Can anyone one help me how to resolve the error? 谁能帮助我解决错误?

Try the solution from https://github.com/locustio/locust/issues/417 https://github.com/locustio/locust/issues/417尝试解决方案

How to get rid from “SSL: CERTIFICATE_VERIFY_FAILED” Error 如何摆脱“ SSL:CERTIFICATE_VERIFY_FAILED”错误

On Windows, Python does not look at the system certificate, it uses its own located at ?\\lib\\site-packages\\certifi\\cacert.pem. 在Windows上,Python不会查看系统证书,它使用位于?\\ lib \\ site-packages \\ certifi \\ cacert.pem的证书。

The solution to your problem: 解决问题的方法:

  1. download the domain validation certificate as *.crt or *pem file 将域验证证书下载为* .crt或* pem文件
  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; 找到您的cacert.pem位置:从request.utils导入DEFAULT_CA_BUNDLE_PATH; print(DEFAULT_CA_BUNDLE_PATH) 打印(DEFAULT_CA_BUNDLE_PATH)
  4. edit the cacert.pem file and paste your domain validation certificate at the end of the file. 编辑cacert.pem文件,然后将域验证证书粘贴到该文件的末尾。
  5. Save the file and enjoy requests! 保存文件并享受请求!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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