Created
April 19, 2018 22:34
-
-
Save William-Hill/2f7e2be3c6ab133a48ce0cf42a3c5007 to your computer and use it in GitHub Desktop.
Get X509 subject name as string using Pyopenssl
This file contains 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 OpenSSL | |
def get_x509_subject_string(cert_name): | |
x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, open(cert_name).read()) | |
subject_components = x509.get_subject().get_components() | |
subject_string = "" | |
for component in subject_components: | |
subject_string = subject_string + "/" + component[0] + "=" + component[1] | |
return subject_string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment