On Fri, 5 Nov 2021 at 12:24, Valerio Pachera <siri...@gmail.com> wrote:
> 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 ... È un istanza di Name [1] , come indicato qua [2]. > 1) Come posso ricavare/estrapolare il valore "nomeprincipale.domain.tld" ? O iteri su cert.subject e finché trovi il risultato che ti serve, oppure usi il metodo get_attributes_for_oid() come dice la documentazione di Name. from cryptography.x509.oid import NameOID ⋮ common_name = cert.subject.get_attributes_for_oid(NameOID.COMMON_NAME) > 2) Come posso ricavare i Subject Alternative Names? Analogamente ma come in [3]: from cryptography.x509.oid import ExtensionOID ⋮ san = cert.extensions.get_extension_for_oid(ExtensionOID.SUBJECT_ALTERNATIVE_NAME) [1]: https://cryptography.io/en/latest/x509/reference/#cryptography.x509.Name [2]: https://cryptography.io/en/latest/x509/reference/#cryptography.x509.Certificate.subject [3]: https://cryptography.io/en/latest/x509/reference/?highlight=subjectaltname#cryptography.x509.SubjectAlternativeName -- Andrea D'Amore _______________________________________________ Python mailing list Python@lists.python.it https://lists.python.it/mailman/listinfo/python