Created
January 25, 2017 00:40
-
-
Save void-elf/956d92002203ea1b4f2fa0a011eed5cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from cryptography import x509 | |
| from cryptography.hazmat.primitives import hashes | |
| from cryptography.hazmat.primitives.asymmetric import padding | |
| from cryptography.hazmat.backends import default_backend | |
| cert_file = open('/etc/letsencrypt/live/www.example.com/cert.pem') | |
| cert_data = cert_file.read() | |
| cert = x509.load_pem_x509_certificate(data=cert_data, backend=default_backend()) | |
| cert_pk = cert.public_key() | |
| cert_pn = cert_pk.public_numbers() | |
| chain_file = open('/etc/letsencrypt/live/www.example.com/chain.pem') | |
| chain_data = chain_file.read() | |
| chain = x509.load_pem_x509_certificate(data=chain_data, backend=default_backend()) | |
| chain_pk = chain.public_key() | |
| chain_pn = chain_pk.public_numbers() | |
| """ | |
| fullchain_file = open('/etc/letsencrypt/live/www.example.com/fullchain.pem') | |
| fullchain_data = fullchain_file.read() | |
| fullchain = x509.load_pem_x509_certificate(data=fullchain_data, backend=default_backend()) | |
| fullchain_pk = fullchain.public_key() | |
| fullchain_pn = fullchain_pk.public_numbers() | |
| """ | |
| privkey_file = open('/etc/letsencrypt/live/www.example.com/privkey.pem') | |
| privkey_data = privkey_file.read() | |
| import ipdb; ipdb.set_trace() | |
| #public_key = cert.public_key() | |
| public_key = chain.public_key() | |
| verifier = public_key.verifier( | |
| signature = cert.signature, | |
| padding = padding.PSS( | |
| mgf = padding.MGF1(hashes.SHA256()), | |
| salt_length = padding.PSS.MAX_LENGTH), | |
| algorithm = hashes.SHA256() | |
| ) | |
| verifier.update(cert.tbs_certificate_bytes) | |
| #verifier.update(cert_data) | |
| verifier.verify() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment