Skip to content

Commit

Permalink
add support for Context.set_cert_store
Browse files Browse the repository at this point in the history
  • Loading branch information
reaperhulk committed May 31, 2023
1 parent 5134ca1 commit 4664eb8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Deprecations:
Changes:
^^^^^^^^

- Added ``Context.set_cert_store`` `#1210 <https://github.com/pyca/pyopenssl/pull/1210>`_.

23.2.0 (2023-05-30)
-------------------

Expand Down
10 changes: 10 additions & 0 deletions src/OpenSSL/SSL.py
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,16 @@ def get_cert_store(self):
pystore._store = store
return pystore

def set_cert_store(self, store):
"""
Set the certificate store for the context.
:param store: A X509Store object.
:return: None
"""
rc = _lib.X509_STORE_up_ref(store._store)
_openssl_assert(rc == 1)
_lib.SSL_CTX_set_cert_store(self._context, store._store)

def set_options(self, options):
"""
Add options. Options set before are not cleared!
Expand Down
6 changes: 6 additions & 0 deletions tests/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,12 @@ def test_get_cert_store(self):
store = context.get_cert_store()
assert isinstance(store, X509Store)

def test_set_cert_store(self):
context = Context(SSLv23_METHOD)
store = X509Store()
context.set_cert_store(store)
assert store._store == context.get_cert_store()._store

def test_set_tlsext_use_srtp_not_bytes(self):
"""
`Context.set_tlsext_use_srtp' enables negotiating SRTP keying material.
Expand Down

0 comments on commit 4664eb8

Please sign in to comment.