-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Connection.get_certificate method #733
Conversation
""" | ||
cert = _lib.SSL_get_certificate(self._ssl) | ||
if cert != _ffi.NULL: | ||
_lib.X509_up_ref(cert) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike SSL.get_peer_certificate, we don't own the X509 pointer. We need to increase the reference count to avoid the X509 freeing the pointer on GC.
f3ea222
to
ebf80ce
Compare
Codecov Report
@@ Coverage Diff @@
## master #733 +/- ##
==========================================
+ Coverage 97.05% 97.06% +<.01%
==========================================
Files 18 18
Lines 5705 5723 +18
Branches 395 396 +1
==========================================
+ Hits 5537 5555 +18
Misses 112 112
Partials 56 56
Continue to review full report at Codecov.
|
4bb9909
to
3d72783
Compare
As far as I can tell, this pull request is complete : tests, docstring and an entry in api/ssl.rst. All that's needed is for cryptography 2.2 to be released. |
I will be circling around to figure out a rough release date for 2.2 next week. |
8b7bc04
to
ee0d412
Compare
Okay, this can be updated to set cryptography 2.2 as minimum version |
OK, so this requires #742 |
This makes it possible to retrieve the local certificate (if any) for a Connection. An example where this is useful is when negotiating a DTLS-SRTP connection, the fingerprint of the local certificate needs to be communicated to the remote party out-of-band via SDP.
197: Scheduled weekly dependency update for week 20 r=mithrandi a=pyup-bot ### Update [hypothesis](https://pypi.org/project/hypothesis) from **3.56.5** to **3.57.0**. *The bot wasn't able to find a changelog for this release. [Got an idea?](/~https://github.com/pyupio/changelogs/issues/new)* <details> <summary>Links</summary> - PyPI: https://pypi.org/project/hypothesis - Repo: /~https://github.com/HypothesisWorks/hypothesis/issues </details> ### Update [pbr](https://pypi.org/project/pbr) from **4.0.2** to **4.0.3**. *The bot wasn't able to find a changelog for this release. [Got an idea?](/~https://github.com/pyupio/changelogs/issues/new)* <details> <summary>Links</summary> - PyPI: https://pypi.org/project/pbr - Homepage: https://docs.openstack.org/pbr/latest/ </details> ### Update [pyopenssl](https://pypi.org/project/pyopenssl) from **17.5.0** to **18.0.0**. <details> <summary>Changelog</summary> ### 18.0.0 ``` ------------------- Backward-incompatible changes: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - The minimum ``cryptography`` version is now 2.2.1. - Support for Python 2.6 has been dropped. Deprecations: ^^^^^^^^^^^^^ *none* Changes: ^^^^^^^^ - Added ``Connection.get_certificate`` to retrieve the local certificate. `733 </~https://github.com/pyca/pyopenssl/pull/733>`_ - ``OpenSSL.SSL.Connection`` now sets ``SSL_MODE_AUTO_RETRY`` by default. `753 </~https://github.com/pyca/pyopenssl/pull/753>`_ - Added ``Context.set_tlsext_use_srtp`` to enable negotiation of SRTP keying material. `734 </~https://github.com/pyca/pyopenssl/pull/734>`_ ---- ``` </details> <details> <summary>Links</summary> - PyPI: https://pypi.org/project/pyopenssl - Changelog: https://pyup.io/changelogs/pyopenssl/ - Homepage: https://pyopenssl.org/ - Docs: https://pythonhosted.org/pyOpenSSL/ </details>
134: Scheduled weekly dependency update for week 20 r=mithrandi a=pyup-bot ### Update [pyopenssl](https://pypi.org/project/pyopenssl) from **17.5.0** to **18.0.0**. <details> <summary>Changelog</summary> ### 18.0.0 ``` ------------------- Backward-incompatible changes: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - The minimum ``cryptography`` version is now 2.2.1. - Support for Python 2.6 has been dropped. Deprecations: ^^^^^^^^^^^^^ *none* Changes: ^^^^^^^^ - Added ``Connection.get_certificate`` to retrieve the local certificate. `733 </~https://github.com/pyca/pyopenssl/pull/733>`_ - ``OpenSSL.SSL.Connection`` now sets ``SSL_MODE_AUTO_RETRY`` by default. `753 </~https://github.com/pyca/pyopenssl/pull/753>`_ - Added ``Context.set_tlsext_use_srtp`` to enable negotiation of SRTP keying material. `734 </~https://github.com/pyca/pyopenssl/pull/734>`_ ---- ``` </details> <details> <summary>Links</summary> - PyPI: https://pypi.org/project/pyopenssl - Changelog: https://pyup.io/changelogs/pyopenssl/ - Homepage: https://pyopenssl.org/ - Docs: https://pythonhosted.org/pyOpenSSL/ </details>
188: Scheduled weekly dependency update for week 21 r=mithrandi a=pyup-bot ### Update [pyasn1](https://pypi.org/project/pyasn1) from **0.4.2** to **0.4.3**. *The bot wasn't able to find a changelog for this release. [Got an idea?](/~https://github.com/pyupio/changelogs/issues/new)* <details> <summary>Links</summary> - PyPI: https://pypi.org/project/pyasn1 - Changelog: https://pyup.io/changelogs/pyasn1/ - Repo: /~https://github.com/etingof/pyasn1 </details> ### Update [pyopenssl](https://pypi.org/project/pyopenssl) from **17.5.0** to **18.0.0**. <details> <summary>Changelog</summary> ### 18.0.0 ``` ------------------- Backward-incompatible changes: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - The minimum ``cryptography`` version is now 2.2.1. - Support for Python 2.6 has been dropped. Deprecations: ^^^^^^^^^^^^^ *none* Changes: ^^^^^^^^ - Added ``Connection.get_certificate`` to retrieve the local certificate. `733 </~https://github.com/pyca/pyopenssl/pull/733>`_ - ``OpenSSL.SSL.Connection`` now sets ``SSL_MODE_AUTO_RETRY`` by default. `753 </~https://github.com/pyca/pyopenssl/pull/753>`_ - Added ``Context.set_tlsext_use_srtp`` to enable negotiation of SRTP keying material. `734 </~https://github.com/pyca/pyopenssl/pull/734>`_ ---- ``` </details> <details> <summary>Links</summary> - PyPI: https://pypi.org/project/pyopenssl - Changelog: https://pyup.io/changelogs/pyopenssl/ - Homepage: https://pyopenssl.org/ - Docs: https://pythonhosted.org/pyOpenSSL/ </details> ### Update [python-dateutil](https://pypi.org/project/python-dateutil) from **2.7.2** to **2.7.3**. *The bot wasn't able to find a changelog for this release. [Got an idea?](/~https://github.com/pyupio/changelogs/issues/new)* <details> <summary>Links</summary> - PyPI: https://pypi.org/project/python-dateutil - Changelog: https://pyup.io/changelogs/python-dateutil/ - Docs: https://dateutil.readthedocs.io </details> Co-authored-by: pyup-bot <github-bot@pyup.io>
This makes it possible to retrieve the local certificate (if any)
for a Connection.
An example where this is useful is when negotiating a DTLS-SRTP
connection, the fingerprint of the local certificate needs to be
communicated to the remote party out-of-band via SDP.
This depends on:
pyca/cryptography#4100