From 63c6caf7cb3e0c271fce6dbbf2e7baef55426151 Mon Sep 17 00:00:00 2001 From: Daniel Roesler Date: Sun, 8 Nov 2015 11:50:39 -0800 Subject: attempt to fix #16 modulus parsing for OSX openssl 0.9.8zg, which has 'Modulus (4096 bit):' instead of 'Modulus:' --- sign_csr.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sign_csr.py b/sign_csr.py index 643fbb0..28b5257 100644 --- a/sign_csr.py +++ b/sign_csr.py @@ -36,7 +36,9 @@ def sign_csr(pubkey, csr, email=None): out, err = proc.communicate() if proc.returncode != 0: raise IOError("Error loading {}".format(pubkey)) - pub_hex, pub_exp = re.search("Modulus\:\s+00:([a-f0-9\:\s]+?)Exponent\: ([0-9]+)", out, re.MULTILINE|re.DOTALL).groups() + pub_hex, pub_exp = re.search( + "Modulus(?: \((?:2048|4096) bit\)|)\:\s+00:([a-f0-9\:\s]+?)Exponent\: ([0-9]+)", + out, re.MULTILINE|re.DOTALL).groups() pub_mod = binascii.unhexlify(re.sub("(\s|:)", "", pub_hex)) pub_mod64 = _b64(pub_mod) pub_exp = int(pub_exp) -- cgit v1.2.3