![]() I have learned the feature through articles and Q & A along with OpenSSL and Python documentation.Ĭopy Code def get_certificate(host, port, cert_file_pathname):Ĭontext = SSL.Context(SSL.TLSv1_2_METHOD) I would like to share this code with everyone as I realized that there aren't many article about this topic. You can modify the code to serve your purpose as needed. Notice that I manipulate cert_file_pathname and append the index of the certificate to certfile in the code so that I can store all the downloaded certificate with the same prefix. But you can retrieve other fields as needed. In the code snippet, I iterate through the certificate list and retrieve the certificate's CN, then print out the CN string. The code below is a sample Python snippet that will connect to host (e.g., any at specified port (e.g., 443), download certificate chain from host, and store the certificates on the specified cert_file_pathname (e.g., c:\testfolder\certfile). My purpose is to retrieve certificate chain and store the certificates on my local drive which can be further used in other modules. Not much information was found on this topic. ![]() I searched through lots of public articles and lots of Q & A on this topic. While doing POC, I stumbled upon the versioning conflict of Python 2.7.x and Python 3.7.x. I wrote this article to pass on my knowledge to other developers who might have stumbled upon a different version of Python (Python 2.7.x VS Python 3.7.x) when using OpenSSL to download, view, and save certificates. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |