Search code examples
pythonsslstripe-paymentspyinstallerpyarmor

Stripe TLS CA certificate Issue with pyinstaller


I have been using the stripe python module for my program. When I run my file directly as a .py file it runs without any issues, as soon as I convert it to a exe with pyarmor, which uses pyinstaller, I get a TLS CA certificate missing error.

ERROR:

Unexpected error communicating with Stripe. It looks like there's
probably a configuration issue locally.  If this problem persists, let
us know at [email protected].

(Network error: A OSError was raised with error message Could not find a suitable TLS CA certificate bundle, invalid path: C:\Users\ADMINI~1\AppData\Local\Temp\2\_MEI119082\stripe\data\ca-certificates.crt)

Can anyone help?


Solution

  • I've been dealing with this myself, have you tried a solution like this. It deals with a permissions issue of the executable not allowing the pyfile inside of the exe to directly reference Path Variables. The workaround being that it reads them into a special Path variable that can interface with the environment after it's an exe.

    The best solutions looked something like this:

    def resource_path(relative_path):
        """ Get absolute path to resource, works for dev and for PyInstaller """
        if hasattr(sys, '_MEIPASS'):
            return os.path.join(sys._MEIPASS, relative_path)
    
        return os.path.join(os.path.abspath("."), relative_path)
    

    Original Post of this function

    Could be a completely different issue with pyinstaller though I think it's the same one I'm having.