@@ -32,7 +32,7 @@ def wrap_socket(sock, server_hostname, ssl_context=None):
3232
3333 # create the singleton SSLContext we use
3434 if _context is None : # pragma: no cover
35- _context = _init_context ()
35+ _context = init_context ()
3636
3737 # if an SSLContext is provided then use it instead of default context
3838 _ssl_context = ssl_context or _context
@@ -62,13 +62,21 @@ def wrap_socket(sock, server_hostname, ssl_context=None):
6262 return (ssl_sock , proto )
6363
6464
65- def _init_context ( ):
65+ def init_context ( cert_path = None ):
6666 """
67- Create a pre-configured SSLContext.
67+ Create a new ``SSLContext`` that is correctly set up for an HTTP/2 connection.
68+ This SSL context object can be customized and passed as a parameter to the
69+ :class:`HTTPConnection <hyper.HTTPConnection>` class. Provide your
70+ own certificate file in case you don’t want to use hyper’s default
71+ certificate. The path to the certificate can be absolute or relative
72+ to your working directory.
73+
74+ :param cert_path: (optional) The path to the certificate file.
75+ :returns: An ``SSLContext`` correctly set up for HTTP/2.
6876 """
6977 context = ssl .SSLContext (ssl .PROTOCOL_SSLv23 )
7078 context .set_default_verify_paths ()
71- context .load_verify_locations (cafile = cert_loc )
79+ context .load_verify_locations (cafile = cert_path or cert_loc )
7280 context .verify_mode = ssl .CERT_REQUIRED
7381 context .check_hostname = True
7482
0 commit comments