当打包为OS X .app时,请求中的SSLError [英] SSLError in Requests when packaging as OS X .app

查看:76
本文介绍了当打包为OS X .app时,请求中的SSLError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为OS X开发一个应用程序.该应用程序涉及使用安全连接通过python请求与服务器进行通信.

I'm developing an application for OS X. The application involves communicating with a server through python-requests, using a secure connection.

我能够运行要打包的python文件,并且通过SSL连接成功.但是,当我使用py2app打包文件并尝试运行它时,出现以下错误:

I am able to run the python file I intend to package, and it succeeds with the SSL connection. However, when I package the file with py2app and try to run it, I get the following error:

Traceback (most recent call last):
File "/Users/yossi/Documents/repos/drunken-octo-nemesis/dist/drunken-octo.app/Contents/Resources/__boot__.py", line 338, in <module>
    _run()
File "/Users/yossi/Documents/repos/drunken-octo-nemesis/dist/drunken-octo.app/Contents/Resources/__boot__.py", line 333, in _run
    exec(compile(source, path, 'exec'), globals(), globals())
File "/Users/yossi/Documents/repos/drunken-octo-nemesis/dist/drunken-octo.app/Contents/Resources/media_test.py", line 16, in <module>
    cmpbl.syncWithCloud()
File "src/compare_book_lists.pyc", line 172, in syncWithCloud
File "src/compare_book_lists.pyc", line 64, in checkMediaOnCloud
File "src/get_cloud_book_list.pyc", line 26, in getCloudFulfilledBookList
File "requests/api.pyc", line 55, in get
File "requests/api.pyc", line 44, in request
File "requests/sessions.pyc", line 354, in request
File "requests/sessions.pyc", line 460, in send
File "requests/adapters.pyc", line 250, in send
requests.exceptions.SSLError: [Errno 185090050] _ssl.c:340: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib
2013-06-12 11:39:49.119 drunken-octo[1656:707] drunken-octo Error

我能够成功打包部分应用程序.当目标文件在请求链中的某个位置依赖于请求时,问题就开始了.

I was able to package part of my application successfully. The problem begins when the target file depends, somewhere in the chain, on Requests.

我正在使用zc.buildout来组织我的导入.因此,我在由buildout创建的本地python解释器中运行,因此,不幸的是,如果不涉及修改系统Python的话,任何修复程序都将更易于实现.但是,所有建议都是值得欢迎的,我会尽我所能针对我的具体情况对其进行修改.

I am using zc.buildout to organize my imports. Therefore, I am running in a local python interpreter created by the buildout, so any fixes, unfortunately, will be easier to implement if they don't involve modifying the system Python. However, all suggestions are welcome, and I'll do my best to modify them for my specifics.

这仅在我运行打包的应用程序时发生.有什么想法吗?

This only happens when I run the packaged app. Any ideas?

推荐答案

最简单的解决方法是将py2app选项添加到setup.py文件中:

The easiests workaround is to add an option for py2app to your setup.py file:

setup(
   ...
   options={
      'py2app':{
          'packages': [ 'requests' ]
       }
   }
)

这包括将整个软件包包含在应用程序捆绑包中,包括证书捆绑包.

This includes the entire package into the application bundle, including the certificate bundle.

我已经提交了在我的py2app跟踪器中此问题,未来的py2app版本将包含逻辑来检测请求库的使用,并将自动复制证书捆绑包.

I've filed an issue for this in my py2app tracker, a future version of py2app will include logic to detect the use of the request library and will copy the certificate bundle automaticly.

这篇关于当打包为OS X .app时,请求中的SSLError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆