@@ -536,20 +536,28 @@ Constants
536536.. data :: CERT_NONE
537537
538538 Possible value for :attr: `SSLContext.verify_mode `, or the ``cert_reqs ``
539- parameter to :func: `wrap_socket `. In this mode (the default), no
540- certificates will be required from the other side of the socket connection.
541- If a certificate is received from the other end, no attempt to validate it
542- is made.
539+ parameter to :func: `wrap_socket `. Except for :const: `PROTOCOL_TLS_CLIENT `,
540+ it is the default mode. With client-side sockets, just about any
541+ cert is accepted. Validation errors, such as untrusted or expired cert,
542+ are ignored and do not abort the TLS/SSL handshake.
543+
544+ In server mode, no certificate is requested from the client, so the client
545+ does not send any for client cert authentication.
543546
544547 See the discussion of :ref: `ssl-security ` below.
545548
546549.. data :: CERT_OPTIONAL
547550
548551 Possible value for :attr: `SSLContext.verify_mode `, or the ``cert_reqs ``
549- parameter to :func: `wrap_socket `. In this mode no certificates will be
550- required from the other side of the socket connection; but if they
551- are provided, validation will be attempted and an :class: `SSLError `
552- will be raised on failure.
552+ parameter to :func: `wrap_socket `. In client mode, :const: `CERT_OPTIONAL `
553+ has the same meaning as :const: `CERT_REQUIRED `. It is recommended to
554+ use :const: `CERT_REQUIRED ` for client-side sockets instead.
555+
556+ In server mode, a client certificate request is sent to the client. The
557+ client may either ignore the request or send a certificate in order
558+ perform TLS client cert authentication. If the client chooses to send
559+ a certificate, it is verified. Any verification error immediately aborts
560+ the TLS handshake.
553561
554562 Use of this setting requires a valid set of CA certificates to
555563 be passed, either to :meth: `SSLContext.load_verify_locations ` or as a
@@ -561,6 +569,15 @@ Constants
561569 parameter to :func: `wrap_socket `. In this mode, certificates are
562570 required from the other side of the socket connection; an :class: `SSLError `
563571 will be raised if no certificate is provided, or if its validation fails.
572+ This mode is **not ** sufficient to verify a certificate in client mode as
573+ it does not match hostnames. :attr: `~SSLContext.check_hostname ` must be
574+ enabled as well to verify the authenticity of a cert.
575+ :const: `PROTOCOL_TLS_CLIENT ` uses :const: `CERT_REQUIRED ` and
576+ enables :attr: `~SSLContext.check_hostname ` by default.
577+
578+ With server socket, this mode provides mandatory TLS client cert
579+ authentication. A client certificate request is sent to the client and
580+ the client must provide a valid and trusted certificate.
564581
565582 Use of this setting requires a valid set of CA certificates to
566583 be passed, either to :meth: `SSLContext.load_verify_locations ` or as a
@@ -2272,11 +2289,6 @@ In server mode, if you want to authenticate your clients using the SSL layer
22722289(rather than using a higher-level authentication mechanism), you'll also have
22732290to specify :const: `CERT_REQUIRED ` and similarly check the client certificate.
22742291
2275- .. note ::
2276-
2277- In client mode, :const: `CERT_OPTIONAL ` and :const: `CERT_REQUIRED ` are
2278- equivalent unless anonymous ciphers are enabled (they are disabled
2279- by default).
22802292
22812293Protocol versions
22822294'''''''''''''''''
0 commit comments