Skip to content
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

Implement experimental support for public key pinning #24

Closed
sethmlarson opened this issue Sep 30, 2021 · 0 comments · Fixed by #27
Closed

Implement experimental support for public key pinning #24

sethmlarson opened this issue Sep 30, 2021 · 0 comments · Fixed by #27

Comments

@sethmlarson
Copy link
Contributor

sethmlarson commented Sep 30, 2021

In CPython 3.10 there were private APIs SSLObject.get_verified_chain() and _ssl.Certificate.public_bytes(_ssl.ENCODING_DER) methods added.

Ref: python/cpython#25467

import hashlib
import _ssl
fingerprints = [hashlib.sha256(cert.public_bytes(_ssl.ENCODING_DER)).hexdigest() for cert in sock._sslobj.get_verified_chain()]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant