Created
September 8, 2022 07:06
-
-
Save emailandxu/a7ee0e52f205f947903e21ce4e052218 to your computer and use it in GitHub Desktop.
print and validate ssl certificate
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
| import os, ssl, certifi | |
| # adress | |
| host, port = "baidu.com", "443" | |
| # the ca relative path | |
| ca_certs=os.path.relpath(certifi.where()) | |
| # Retrieve the server certificate, validate the certificate by specify the ca_certs arg | |
| cert = ssl.get_server_certificate((host, port), ca_certs=ca_certs) | |
| # print the cert | |
| print(cert) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment