Skip to content

Commit

Permalink
Import certifi certificates when packaged using pyinstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrob committed Jan 20, 2024
1 parent eb32990 commit d253f64
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions emailproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2490,6 +2490,16 @@ def init_platforms(self):
# proxy's handling of this signal may change in future if other actions are seen as more suitable
signal.signal(signal.SIGUSR1, lambda _signum, _fr: self.toggle_debug(Log.get_level() == logging.INFO))

# certificates are not imported automatically when packaged using pyinstaller - we need certifi
if getattr(sys, 'frozen', False):
if ssl.get_default_verify_paths().cafile is None and 'SSL_CERT_FILE' not in os.environ:
try:
import certifi
os.environ['SSL_CERT_FILE'] = certifi.where()
Log.info('Running in a packaged/frozen environment - imported SSL certificates from `certifi`')
except ImportError:
Log.info('Unable to find `certifi` in a packaged/frozen environment - SSL connections may fail')

# noinspection PyUnresolvedReferences,PyAttributeOutsideInit
def macos_nsworkspace_notification_listener_(self, notification):
notification_name = notification.name()
Expand Down

0 comments on commit d253f64

Please sign in to comment.