|  | 
| 33 | 33 |     "X509Req", | 
| 34 | 34 |     "X509", | 
| 35 | 35 |     "X509StoreFlags", | 
|  | 36 | +    "X509StorePurposes", | 
| 36 | 37 |     "X509Store", | 
| 37 | 38 |     "X509StoreContextError", | 
| 38 | 39 |     "X509StoreContext", | 
| @@ -1583,6 +1584,28 @@ class X509StoreFlags: | 
| 1583 | 1584 |     CHECK_SS_SIGNATURE = _lib.X509_V_FLAG_CHECK_SS_SIGNATURE | 
| 1584 | 1585 | 
 | 
| 1585 | 1586 | 
 | 
|  | 1587 | +class X509StorePurposes: | 
|  | 1588 | +    """ | 
|  | 1589 | +    Flags for X509 verification, used to change the behavior of | 
|  | 1590 | +    :class:`X509Store`. | 
|  | 1591 | +
 | 
|  | 1592 | +    See `OpenSSL check purpose`_ for details. | 
|  | 1593 | +
 | 
|  | 1594 | +    .. _OpenSSL check purpose: | 
|  | 1595 | +        https://www.openssl.org/docs/manmaster/man3/X509_check_purpose.html | 
|  | 1596 | +    """ | 
|  | 1597 | + | 
|  | 1598 | +    X509_PURPOSE_SSL_CLIENT = _lib.X509_PURPOSE_SSL_CLIENT | 
|  | 1599 | +    X509_PURPOSE_SSL_SERVER = _lib.X509_PURPOSE_SSL_SERVER | 
|  | 1600 | +    X509_PURPOSE_NS_SSL_SERVER = _lib.X509_PURPOSE_NS_SSL_SERVER | 
|  | 1601 | +    X509_PURPOSE_SMIME_SIGN = _lib.X509_PURPOSE_SMIME_SIGN | 
|  | 1602 | +    X509_PURPOSE_SMIME_ENCRYPT = _lib.X509_PURPOSE_SMIME_ENCRYPT | 
|  | 1603 | +    X509_PURPOSE_CRL_SIGN = _lib.X509_PURPOSE_CRL_SIGN | 
|  | 1604 | +    X509_PURPOSE_ANY = _lib.X509_PURPOSE_ANY | 
|  | 1605 | +    X509_PURPOSE_OCSP_HELPER = _lib.X509_PURPOSE_OCSP_HELPER | 
|  | 1606 | +    X509_PURPOSE_TIMESTAMP_SIGN = _lib.X509_PURPOSE_TIMESTAMP_SIGN | 
|  | 1607 | + | 
|  | 1608 | + | 
| 1586 | 1609 | class X509Store: | 
| 1587 | 1610 |     """ | 
| 1588 | 1611 |     An X.509 store. | 
| @@ -1687,6 +1710,22 @@ def set_time(self, vfy_time): | 
| 1687 | 1710 |         ) | 
| 1688 | 1711 |         _openssl_assert(_lib.X509_STORE_set1_param(self._store, param) != 0) | 
| 1689 | 1712 | 
 | 
|  | 1713 | +    def set_purpose(self, purpose): | 
|  | 1714 | +        """ | 
|  | 1715 | +        Set purpose of this store. | 
|  | 1716 | +
 | 
|  | 1717 | +        .. versionadded:: 22.1.0 | 
|  | 1718 | +
 | 
|  | 1719 | +        :param int flags: The verification flags to set on this store. | 
|  | 1720 | +            See :class:`X509StorePurposes` for available constants. | 
|  | 1721 | +        :return: ``None`` if the verification flags were successfully set. | 
|  | 1722 | +        """ | 
|  | 1723 | + | 
|  | 1724 | +        param = _lib.X509_VERIFY_PARAM_new() | 
|  | 1725 | +        param = _ffi.gc(param, _lib.X509_VERIFY_PARAM_free) | 
|  | 1726 | +        _lib.X509_VERIFY_PARAM_set_purpose(param, purpose) | 
|  | 1727 | +        _openssl_assert(_lib.X509_STORE_set1_param(self._store, param) != 0) | 
|  | 1728 | + | 
| 1690 | 1729 |     def load_locations(self, cafile, capath=None): | 
| 1691 | 1730 |         """ | 
| 1692 | 1731 |         Let X509Store know where we can find trusted certificates for the | 
|  | 
0 commit comments