Skip to content

Commit d253f64

Browse files
committed
Import certifi certificates when packaged using pyinstaller
1 parent eb32990 commit d253f64

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

emailproxy.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,6 +2490,16 @@ def init_platforms(self):
24902490
# proxy's handling of this signal may change in future if other actions are seen as more suitable
24912491
signal.signal(signal.SIGUSR1, lambda _signum, _fr: self.toggle_debug(Log.get_level() == logging.INFO))
24922492

2493+
# certificates are not imported automatically when packaged using pyinstaller - we need certifi
2494+
if getattr(sys, 'frozen', False):
2495+
if ssl.get_default_verify_paths().cafile is None and 'SSL_CERT_FILE' not in os.environ:
2496+
try:
2497+
import certifi
2498+
os.environ['SSL_CERT_FILE'] = certifi.where()
2499+
Log.info('Running in a packaged/frozen environment - imported SSL certificates from `certifi`')
2500+
except ImportError:
2501+
Log.info('Unable to find `certifi` in a packaged/frozen environment - SSL connections may fail')
2502+
24932503
# noinspection PyUnresolvedReferences,PyAttributeOutsideInit
24942504
def macos_nsworkspace_notification_listener_(self, notification):
24952505
notification_name = notification.name()

0 commit comments

Comments
 (0)