From bf74fe286e02b1bd88b5d720444f65a49a3f59d8 Mon Sep 17 00:00:00 2001 From: Seth Schoen Date: Fri, 29 Jun 2012 17:25:56 -0700 Subject: [PATCH] a clean subject_names() function --- client-webserver/pkcs10.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/client-webserver/pkcs10.py b/client-webserver/pkcs10.py index 42757e4df..7bbca537e 100644 --- a/client-webserver/pkcs10.py +++ b/client-webserver/pkcs10.py @@ -72,20 +72,12 @@ def load_certificate_request(csr): return nss.CertificateRequest(substrate) -if __name__ == '__main__': - nss.nss_init_nodb() - - # Read PEM request from stdin and print out its components - - csrlines = sys.stdin.readlines() - # csrlines = fp.readlines() - # fp.close() - csr = ''.join(csrlines) +def subject_names(csr): + if not nss.nss_is_initialized(): + nss.nss_init_nodb() csr = load_certificate_request(csr) - # print csr - sans = get_subjectaltname(csr) if not sans: sans = [] - print [x.split("=")[1] for x in [f for f in str(get_subject(csr)).split(",") if f[:3] == "CN="]] + list(sans) + return [x.split("=")[1] for x in [f for f in str(get_subject(csr)).split(",") if f[:3] == "CN="]] + list(sans)