加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – Errno 185090050 _ssl.c:343:错误:0B084002:x509

发布时间:2020-12-20 13:41:54 所属栏目:Python 来源:网络整理
导读:我编写了一个 python脚本来检查GCS中的文件,它使用wxpython来生成GUI.要进行身份验证,我是这样做的(按照Google示例代码中的方式 – http://code.google.com/p/google-cloud-platform-samples/source/browse/file-transfer-json/chunked_transfer.py?repo=sto
我编写了一个 python脚本来检查GCS中的文件,它使用wxpython来生成GUI.要进行身份验证,我是这样做的(按照Google示例代码中的方式 – > http://code.google.com/p/google-cloud-platform-samples/source/browse/file-transfer-json/chunked_transfer.py?repo=storage):

flow = flow_from_clientsecrets(CLIENT_SECRETS_FILE,# the secrets file I put in same folder
                               scope=scope,message=MISSING_CLIENT_SECRETS_MESSAGE)

credential_storage = CredentialStorage(CREDENTIALS_FILE) # the file to store
                                                    # authentication credentials
credentials = credential_storage.get()
if credentials is None or credentials.invalid:
    credentials = run_oauth2(flow,credential_storage)

self.printLog('Constructing Google Cloud Storage service...')
http = credentials.authorize(httplib2.Http())
return discovery_build('storage','v1beta1',http=http)

上面的代码包含在我的Python脚本中,当它只是一个python .py文件时效果很好,后来我使用pyinstaller将它转换为.exe在win 7 64bit(我也把秘密文件放在同一个文件夹中) .exe文件)使用下面的命令

C:gcs_file_check>python pyinstaller-2.0pyinstaller.py -w
gcs_file_check.py

当点击exe时,Google的“权限请求”页面正确启动(就像运行Python脚本而不是exe脚本一样),但是在我单击“Accept”之后,上面的代码将抛出异常:

[Errno 185090050] _ssl.c:343: error:0B084002:x509 certificate
routines:X509_load_cert_crl_file:system lib

我可以看到文件credentials.json不是由.exe创建的,而Python脚本可以正确创建此文件.

有人知道这是如何发生的以及如何解决?感谢每一个答案!

===================

2016年4月16日更新:

我添加了调试代码,发现异常完全来自以下代码:

if credentials is None or credentials.invalid:
    credentials = run_oauth2(flow,credential_storage)

===================

更新:

添加更多细节,以前我使用的是oauth2client.tools.run()

from oauth2client.tools import run as run_oauth2

现在我改为run_flow()作为源代码建议 – > https://google-api-python-client.googlecode.com/hg/docs/epy/oauth2client.tools-pysrc.html#run

from oauth2client.tools import run_flow as run_oauth2

现在这部分代码是:

parser=argparse.ArgumentParser(description=__doc__,formatter_class=argparse.RawDescriptionHelpFormatter,parents=[tools.argparser] )
                     flags = tools.argparser.parse_args(sys.argv[1:])

if credentials is None or credentials.invalid:
    credentials = run_oauth2(flow,credential_storage,flags)

但仍然,python代码运行良好,并在PyInstaller打包到.exe后抛出相同的异常[Errno 185090050].

解决方法

试试这个,https://github.com/kennethreitz/requests/issues/557 “在使用带有Httplib2的pyinstaller时,我也遇到了类似的错误. 您需要将ssl客户端证书文件的路径显式传递给’cert’参数http请求.此外,你需要包装你的. .pem文件作为pyinstaller中的数据文件.“

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读