@@ -51,9 +51,49 @@ handler. Code to create and run the server looks like this::
5151 .. versionadded :: 3.7
5252
5353
54- The :class: `HTTPServer ` and :class: `ThreadingHTTPServer ` must be given
55- a *RequestHandlerClass * on instantiation, of which this module
56- provides three different variants:
54+ .. class :: HTTPSServer(server_address, RequestHandlerClass,\
55+ bind_and_activate=True, *, certfile, keyfile=None,\
56+ password=None, alpn_protocols=None)
57+
58+ Subclass of :class: `HTTPServer ` with a wrapped socket using the :mod: `ssl ` module.
59+ If the :mod: `ssl ` module is not available, instantiating a :class: `!HTTPSServer `
60+ object fails with a :exc: `RuntimeError `.
61+
62+ The *certfile * argument is the path to the SSL certificate chain file,
63+ and the *keyfile * is the path to file containing the private key.
64+
65+ A *password * can be specified for files protected and wrapped with PKCS#8,
66+ but beware that this could possibly expose hardcoded passwords in clear.
67+
68+ .. seealso ::
69+
70+ See :meth: `ssl.SSLContext.load_cert_chain ` for additional
71+ information on the accepted values for *certfile *, *keyfile *
72+ and *password *.
73+
74+ When specified, the *alpn_protocols * argument must be a sequence of strings
75+ specifying the "Application-Layer Protocol Negotiation" (ALPN) protocols
76+ supported by the server. ALPN allows the server and the client to negotiate
77+ the application protocol during the TLS handshake.
78+
79+ By default, it is set to ``["http/1.1"] ``, meaning the server supports HTTP/1.1.
80+
81+ .. versionadded :: next
82+
83+ .. class :: ThreadingHTTPSServer(server_address, RequestHandlerClass,\
84+ bind_and_activate=True, *, certfile, keyfile=None,\
85+ password=None, alpn_protocols=None)
86+
87+ This class is identical to :class: `HTTPSServer ` but uses threads to handle
88+ requests by inheriting from :class: `~socketserver.ThreadingMixIn `. This is
89+ analogous to :class: `ThreadingHTTPServer ` only using :class: `HTTPSServer `.
90+
91+ .. versionadded :: next
92+
93+
94+ The :class: `HTTPServer `, :class: `ThreadingHTTPServer `, :class: `HTTPSServer ` and
95+ :class: `ThreadingHTTPSServer ` must be given a *RequestHandlerClass * on
96+ instantiation, of which this module provides three different variants:
5797
5898.. class :: BaseHTTPRequestHandler(request, client_address, server)
5999
@@ -542,6 +582,35 @@ The following options are accepted:
542582 are not intended for use by untrusted clients and may be vulnerable
543583 to exploitation. Always use within a secure environment.
544584
585+ .. option :: --tls-cert
586+
587+ Specifies a TLS certificate chain for HTTPS connections::
588+
589+ python -m http.server --tls-cert fullchain.pem
590+
591+ .. versionadded :: next
592+
593+ .. option :: --tls-key
594+
595+ Specifies a private key file for HTTPS connections.
596+
597+ This option requires ``--tls-cert `` to be specified.
598+
599+ .. versionadded :: next
600+
601+ .. option :: --tls-password-file
602+
603+ Specifies the password file for password-protected private keys::
604+
605+ python -m http.server \
606+ --tls-cert cert.pem \
607+ --tls-key key.pem \
608+ --tls-password-file password.txt
609+
610+ This option requires `--tls-cert`` to be specified.
611+
612+ .. versionadded :: next
613+
545614
546615.. _http.server-security :
547616
0 commit comments