首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python3.7和Dataflow - SSL证书问题

Python3.7和Dataflow - SSL证书问题
EN

Stack Overflow用户
提问于 2019-01-21 03:25:34
回答 1查看 1.6K关注 0票数 2

我需要使用来编写我的数据流作业。

据我所知,我不能使用pip install google-cloud-dataflow,因为Apache不会在Python3上工作,所以我一直在使用googleapiclient.discovery。但是,当我发出build()命令时,它会引用错误进行轰炸:

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)

背景说明:

  • 我坐在一个企业代理后面,在环境级别上设置了HTTP(S)_PROXY
  • 我还将CA_BUNDLE和REQUESTS_CA_BUNDLE设置为我的自定义证书
  • 我安装了certifi,但没有爱
  • 我试图运行/Applications/Python\ 3.6/Install\ Certificates.command,但在虚拟服务器中找不到.command。而且,我也不愿意沿着这条路走下去,因为这将使我的刺激部署成为一场噩梦。

这是我的密码:

代码语言:javascript
复制
from oauth2client.client import GoogleCredentials
from googleapiclient.discovery import build

credentials = GoogleCredentials.get_application_default()

dataflow = build('dataflow', 'v1b3', credentials=credentials)

结果:

回溯(最近一次调用):文件"test_dataflow_creds.py",第6行,在dataflow = build('dataflow','v1b3',credentials=credentials)文件positional_wrapper行130中,在positional_wrapper返回包装(*args)中**kwargs)文件"/Users/user/.pyenv/versions/unit-test-3.7/lib/python3.7/site-packages/googleapiclient/discovery.py",行222,在build requested_url,discovery_http,cache_discovery,cache中,_retrieve_discovery_doc resp中的文件"/Users/user/.pyenv/versions/unit-test-3.7/lib/python3.7/site-packages/googleapiclient/discovery.py",行269,"/Users/user/.pyenv/versions/unit-test-3.7/lib/python3.7/site-packages/httplib2/init.py",= http.request(actual_url)文件的第1924行,在_request conn、request_uri、method、body中,在请求缓存键中,在文件"/Users/user/.pyenv/versions/unit-test-3.7/lib/python3.7/site-packages/httplib2/init.py",行1595中,头文件"/Users/user/.pyenv/versions/unit-test-3.7/lib/python3.7/site-packages/httplib2/init.py",第1501行,在_conn_request conn.connect() File "/Users/user/.pyenv/versions/unit-test-3.7/lib/python3.7/site-packages/httplib2/init.py",第1291行中,在connect self.sock = self._context.wrap_socket(sock,文件"/Users/user/.pyenv/versions/3.7.0/lib/python3.7/ssl.py",第412行,wrap_socket session=session文件"/Users/user/.pyenv/versions/3.7.0/lib/python3.7/ssl.py",行850,_create self.do_handshake() "/Users/user/.pyenv/versions/3.7.0/lib/python3.7/ssl.py",第1108行,在do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: SSL: CERTIFICATE_VERIFY_FAILED证书验证失败:无法获得本地颁发者证书(_ssl.c:1045)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-29 23:32:15

tl;dr:通过将所有Certs导出到一个公共文件,然后按照Certifi指定的路径追加到Cert文件,使其工作正常。

步骤:

  1. 在Firefox > Preferences > View证书>您的证书中,导出所有必需的证书。
  2. 将所有上述.crt文件连接到一个大包中。
  3. 在bash中,运行python -m requests.certs来获取python正在使用的certs文件。
  4. 将上述步骤2中的捆绑证书追加到步骤3的文件中。
  5. 完成
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54283148

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档