Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit 951f531

Browse files
A more helpful error for anyone that tries to distribute (such as using Py2Exe) without manually specifying a certificate.
1 parent 53b22fa commit 951f531

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

hyper/tls.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,12 @@ def init_context(cert_path=None, cert=None, cert_password=None):
9696
encrypted and no password is needed.
9797
:returns: An ``SSLContext`` correctly set up for HTTP/2.
9898
"""
99+
cafile = cert_path or cert_loc
100+
if not cafile or not path.exists(cafile):
101+
raise Exception, "No certificate found at " + str(cafile) + ". Either ensure the default cert.pem file is included in the distribution or provide a custom certificate when creating the connection."
99102
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
100103
context.set_default_verify_paths()
101-
context.load_verify_locations(cafile=cert_path or cert_loc)
104+
context.load_verify_locations(cafile=cafile)
102105
context.verify_mode = ssl.CERT_REQUIRED
103106
context.check_hostname = True
104107

0 commit comments

Comments
 (0)