@@ -66,6 +66,7 @@ def deprecated(msg: str, **kwargs: object) -> Callable[[_T], _T]:
66
66
"X509Extension" ,
67
67
"X509Name" ,
68
68
"X509Req" ,
69
+ "X509Purpose" ,
69
70
"X509Store" ,
70
71
"X509StoreContext" ,
71
72
"X509StoreContextError" ,
@@ -1709,6 +1710,28 @@ class X509StoreFlags:
1709
1710
PARTIAL_CHAIN : int = _lib .X509_V_FLAG_PARTIAL_CHAIN
1710
1711
1711
1712
1713
+ class X509Purpose :
1714
+ """
1715
+ Enumeration of X509 purposes, e.g. used to set the purpose of a
1716
+ :class:`X509Store`.
1717
+
1718
+ See `OpenSSL check purpose`_ for details.
1719
+
1720
+ .. _OpenSSL check purpose:
1721
+ https://www.openssl.org/docs/manmaster/man3/X509_check_purpose.html
1722
+ """
1723
+
1724
+ X509_PURPOSE_SSL_CLIENT = _lib .X509_PURPOSE_SSL_CLIENT
1725
+ X509_PURPOSE_SSL_SERVER = _lib .X509_PURPOSE_SSL_SERVER
1726
+ X509_PURPOSE_NS_SSL_SERVER = _lib .X509_PURPOSE_NS_SSL_SERVER
1727
+ X509_PURPOSE_SMIME_SIGN = _lib .X509_PURPOSE_SMIME_SIGN
1728
+ X509_PURPOSE_SMIME_ENCRYPT = _lib .X509_PURPOSE_SMIME_ENCRYPT
1729
+ X509_PURPOSE_CRL_SIGN = _lib .X509_PURPOSE_CRL_SIGN
1730
+ X509_PURPOSE_ANY = _lib .X509_PURPOSE_ANY
1731
+ X509_PURPOSE_OCSP_HELPER = _lib .X509_PURPOSE_OCSP_HELPER
1732
+ X509_PURPOSE_TIMESTAMP_SIGN = _lib .X509_PURPOSE_TIMESTAMP_SIGN
1733
+
1734
+
1712
1735
class X509Store :
1713
1736
"""
1714
1737
An X.509 store.
@@ -1832,6 +1855,21 @@ def load_locations(
1832
1855
cafile : StrOrBytesPath | None ,
1833
1856
capath : StrOrBytesPath | None = None ,
1834
1857
) -> None :
1858
+
1859
+ def set_purpose (self , purpose ):
1860
+ """
1861
+ Set purpose of this store.
1862
+
1863
+ .. versionadded:: 26.0.0
1864
+
1865
+ :param int flags: The verification flags to set on this store.
1866
+ See :class:`X509StorePurposes` for available constants.
1867
+ :return: ``None`` if the verification flags were successfully set.
1868
+ """
1869
+ _openssl_assert (_lib .X509_STORE_set_purpose (self ._store , purpose ) != 0 )
1870
+
1871
+
1872
+ def load_locations (self , cafile , capath = None ):
1835
1873
"""
1836
1874
Let X509Store know where we can find trusted certificates for the
1837
1875
certificate chain. Note that the certificates have to be in PEM
0 commit comments