File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -499,9 +499,9 @@ Constants
499
499
500
500
.. data :: VERIFY_DEFAULT
501
501
502
- Possible value for :attr: `SSLContext.verify_flags `. In this mode,
503
- certificate revocation lists (CRLs) are not checked. By default OpenSSL
504
- does neither require nor verify CRLs.
502
+ Possible value for :attr: `SSLContext.verify_flags `. In this mode, certificate
503
+ revocation lists (CRLs) are not checked. By default OpenSSL does neither
504
+ require nor verify CRLs.
505
505
506
506
.. versionadded :: 3.4
507
507
@@ -529,6 +529,14 @@ Constants
529
529
530
530
.. versionadded :: 3.4
531
531
532
+ .. data :: VERIFY_X509_TRUSTED_FIRST
533
+
534
+ Possible value for :attr: `SSLContext.verify_flags `. It instructs OpenSSL to
535
+ prefer trusted certificates when building the trust chain to validate a
536
+ certificate. This flag is enabled by default.
537
+
538
+ .. versionadded :: 3.4.5
539
+
532
540
.. data :: PROTOCOL_SSLv23
533
541
534
542
Selects the highest protocol version that both the client and server support.
Original file line number Diff line number Diff line change @@ -710,8 +710,9 @@ def test_verify_mode(self):
710
710
"verify_flags need OpenSSL > 0.9.8" )
711
711
def test_verify_flags (self ):
712
712
ctx = ssl .SSLContext (ssl .PROTOCOL_TLSv1 )
713
- # default value by OpenSSL
714
- self .assertEqual (ctx .verify_flags , ssl .VERIFY_DEFAULT )
713
+ # default value
714
+ tf = getattr (ssl , "VERIFY_X509_TRUSTED_FIRST" , 0 )
715
+ self .assertEqual (ctx .verify_flags , ssl .VERIFY_DEFAULT | tf )
715
716
ctx .verify_flags = ssl .VERIFY_CRL_CHECK_LEAF
716
717
self .assertEqual (ctx .verify_flags , ssl .VERIFY_CRL_CHECK_LEAF )
717
718
ctx .verify_flags = ssl .VERIFY_CRL_CHECK_CHAIN
Original file line number Diff line number Diff line change @@ -4004,6 +4004,10 @@ PyInit__ssl(void)
4004
4004
X509_V_FLAG_CRL_CHECK |X509_V_FLAG_CRL_CHECK_ALL );
4005
4005
PyModule_AddIntConstant (m , "VERIFY_X509_STRICT" ,
4006
4006
X509_V_FLAG_X509_STRICT );
4007
+ #ifdef X509_V_FLAG_TRUSTED_FIRST
4008
+ PyModule_AddIntConstant (m , "VERIFY_X509_TRUSTED_FIRST" ,
4009
+ X509_V_FLAG_TRUSTED_FIRST );
4010
+ #endif
4007
4011
4008
4012
/* Alert Descriptions from ssl.h */
4009
4013
/* note RESERVED constants no longer intended for use have been removed */
You can’t perform that action at this time.
0 commit comments