-
Notifications
You must be signed in to change notification settings - Fork 90
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
Get a certificate chain with crypto.get_certificate
module
#568
Comments
https://docs.python.org/3/library/ssl.html#ssl.SSLSocket.getpeercert (what we are using) only returns the certificate itself, and a quick glance does not show a way to get hold of the whole chain. Maybe taking a look at the source is more helpful, but the first looks I took myself seem to suggest it is just not possible. |
Is it not possible to use SSLContext.get_ca_certs in the module? It's just a guess, I have not experience with this python module. |
That function is available in Python 2.7 and Python 3.4+ (though not in Python 2.6, which this collection still supports), though that probably isn't a big problem. What I'm more worried about is whether this function actually does what you expect. |
I looked into the
The tracking issue for this functionality seems to be python/cpython#62433, and python/cpython#17938 is a PR providing a stable interface for this. It hasn't been rebased after python/cpython#25467 was merged though, so no idea when it will progress... |
Hello, Felix. Sorry, is there any news about the public API that we can use to solve this issue? Python 3.12 was recently released. Maybe it makes sense to try to implement obtaining information about CA certificates using the currently available library functionality? What do you think? |
It looks Python 3.13 will have such functionality: python/cpython#109113 (python/cpython#109109) |
Once #768 is merged there's Python 3.13 in CI that can be used to test a PR for this feature. |
I've implemented this in #784. The PR has some code for Python 3.10..3.12 that uses the internal APIs, which isn't exactly clean, but works :) Unfortunately there is a bug in the Python 3.13 API right now that hopefully will get fixed soon... |
SUMMARY
Currently,
crypto.get_certificate
module only returns a server certificate itself, but it is more useful to return all certificates sent by the server, as does the-showcerts
option ofopenssl s_client
command.ISSUE TYPE
COMPONENT NAME
crypto.get_certificate
ADDITIONAL INFORMATION
For example, I would like to get CA certificate from a LDAP server and save it as a file in the client's trust store. If I don't already have the certificate saved on disk or in a variable, I should try to parse the command module output.
I don't think any additional options are needed here, just expanding the output.
Sample output:
The text was updated successfully, but these errors were encountered: