@@ -541,20 +541,28 @@ Constants
541
541
.. data :: CERT_NONE
542
542
543
543
Possible value for :attr: `SSLContext.verify_mode `, or the ``cert_reqs ``
544
- parameter to :func: `wrap_socket `. In this mode (the default), no
545
- certificates will be required from the other side of the socket connection.
546
- If a certificate is received from the other end, no attempt to validate it
547
- is made.
544
+ parameter to :func: `wrap_socket `. Except for :const: `PROTOCOL_TLS_CLIENT `,
545
+ it is the default mode. With client-side sockets, just about any
546
+ cert is accepted. Validation errors, such as untrusted or expired cert,
547
+ are ignored and do not abort the TLS/SSL handshake.
548
+
549
+ In server mode, no certificate is requested from the client, so the client
550
+ does not send any for client cert authentication.
548
551
549
552
See the discussion of :ref: `ssl-security ` below.
550
553
551
554
.. data :: CERT_OPTIONAL
552
555
553
556
Possible value for :attr: `SSLContext.verify_mode `, or the ``cert_reqs ``
554
- parameter to :func: `wrap_socket `. In this mode no certificates will be
555
- required from the other side of the socket connection; but if they
556
- are provided, validation will be attempted and an :class: `SSLError `
557
- will be raised on failure.
557
+ parameter to :func: `wrap_socket `. In client mode, :const: `CERT_OPTIONAL `
558
+ has the same meaning as :const: `CERT_REQUIRED `. It is recommended to
559
+ use :const: `CERT_REQUIRED ` for client-side sockets instead.
560
+
561
+ In server mode, a client certificate request is sent to the client. The
562
+ client may either ignore the request or send a certificate in order
563
+ perform TLS client cert authentication. If the client chooses to send
564
+ a certificate, it is verified. Any verification error immediately aborts
565
+ the TLS handshake.
558
566
559
567
Use of this setting requires a valid set of CA certificates to
560
568
be passed, either to :meth: `SSLContext.load_verify_locations ` or as a
@@ -566,6 +574,15 @@ Constants
566
574
parameter to :func: `wrap_socket `. In this mode, certificates are
567
575
required from the other side of the socket connection; an :class: `SSLError `
568
576
will be raised if no certificate is provided, or if its validation fails.
577
+ This mode is **not ** sufficient to verify a certificate in client mode as
578
+ it does not match hostnames. :attr: `~SSLContext.check_hostname ` must be
579
+ enabled as well to verify the authenticity of a cert.
580
+ :const: `PROTOCOL_TLS_CLIENT ` uses :const: `CERT_REQUIRED ` and
581
+ enables :attr: `~SSLContext.check_hostname ` by default.
582
+
583
+ With server socket, this mode provides mandatory TLS client cert
584
+ authentication. A client certificate request is sent to the client and
585
+ the client must provide a valid and trusted certificate.
569
586
570
587
Use of this setting requires a valid set of CA certificates to
571
588
be passed, either to :meth: `SSLContext.load_verify_locations ` or as a
@@ -2537,11 +2554,6 @@ In server mode, if you want to authenticate your clients using the SSL layer
2537
2554
(rather than using a higher-level authentication mechanism), you'll also have
2538
2555
to specify :const: `CERT_REQUIRED ` and similarly check the client certificate.
2539
2556
2540
- .. note ::
2541
-
2542
- In client mode, :const: `CERT_OPTIONAL ` and :const: `CERT_REQUIRED ` are
2543
- equivalent unless anonymous ciphers are enabled (they are disabled
2544
- by default).
2545
2557
2546
2558
Protocol versions
2547
2559
'''''''''''''''''
0 commit comments