SSLError in Requests when packaging as OS X .app

后端 未结 4 1446
傲寒
傲寒 2021-02-06 08:44

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

I am able to run the p

4条回答
  •  礼貌的吻别
    2021-02-06 09:23

    The previous accepted answer did not work for me - maybe the way requests works has changed.

    To resolve this I changed my setup.py options to include the certifi package where the certificate pem file lives:

    OPTIONS = {'argv_emulation': True,'packages': ['certifi']}
    

    Then added this to the python requests calls:

    is_py2app = hasattr(sys, "frozen")
    pem_path = "lib/python2.7/certifi/cacert.pem" if is_py2app else None 
    
    ...
    
    requests.get(..., verify=pem_path)
    

    This may be different on other Python versions.

提交回复
热议问题