Argh ... looks like the mailing list scrubbed 2 of my attachments.
Here is the python code (not as an attachment), hope the mailer does not
mangle it.
import sys
import nss.nss as nss
from nss.error import NSPRError
# Perform basic configuration and setup
nss.nss_init_nodb()
# Get the cert filename from command line argument
filename = sys.argv[1]
print "certificate filename: %s" % (filename)
# Read the certificate from the file
si = nss.read_der_from_file(filename, True)
# Parse the DER encoded data returning a Certificate object
cert = nss.Certificate(si)
# Get the SubjectAltName extension from the cert
try:
extension = cert.get_extension(nss.SEC_OID_X509_SUBJECT_ALT_NAME)
except KeyError:
print "Certificate does not contain a SubjectAltName extension"
sys.exit(1)
# Get the names from the extension
names = nss.x509_alt_name(extension.value)
# Print out the names
print 'certificate subject: %s' % cert.subject
print 'has %d alternate names' % len(names)
for name in names:
print ' %s' % name
# Success
sys.exit(0)
--
John
--
dev-tech-crypto mailing list
dev-tech-crypto@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-crypto