Ciao a tutti, il mio obiettivo è ottenere la lista dei Subject Alternative Name di un certificato.
X509v3 Subject Alternative Name: DNS:nome1.domain.tld , DNS:nome2.domain.tld, DNS:nome3.domain.tld Ho ottenuto un risultato parziale tramite: --- #!/usr/bin/env python3 from pprint import pprint from cryptography import x509 from cryptography.hazmat.backends import default_backend with open('/tmp/file.cer') as f_cert: pem_data = f_cert.read().encode('ascii') cert = x509.load_pem_x509_certificate(pem_data, default_backend()) print(cert.subject) --- Prendendo spunto da https://stackoverflow.com/questions/16899247/how-can-i-decode-a-ssl-certificate-using-python Guardando la documentazione https://cryptography.io/en/latest/x509/reference/#x-509-certificate-object o anche semplicemente tramite print(help(cert)) vedo l'elenco delle "proprietà" che posso richiamare (non so bene come riferirmi). Ad esempio, potrei voler stampare il Common Name tramite print(cert.subject) Non so bene come interpretare l'output che ottengo: <Name([<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName)>, value='nomeprincipale.domain.tld')>])> Non è una lista, stringa, tupla ... 1) Come posso ricavare/estrapolare il valore "nomeprincipale.domain.tld" ? Rispondere a questa domanda sicuramente mi aiuta, ma non ho ancora raggiunto il mio scopo: ottenere la lista dei Subject Alternative Name. Non vedo la possibilità di richiamare qualcosa tipo cert.subject_alternative_name 2) Come posso ricavare i Subject Alternative Names? _______________________________________________ Python mailing list Python@lists.python.it https://lists.python.it/mailman/listinfo/python