summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Roesler <diafygi@gmail.com>2015-06-12 21:39:34 -0700
committerDaniel Roesler <diafygi@gmail.com>2015-06-12 21:39:34 -0700
commit37f414b89e3ea1abeb77b2dca3d567312845dd6c (patch)
tree872f45ad0d2600978c2b3ecba2f54c34c590ba8d
parent67a7e97bbe19d3f184be8c8e59cbd9ac70cce210 (diff)
fixed #2, made loading file errors more friendly
-rw-r--r--sign_csr.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/sign_csr.py b/sign_csr.py
index 85cc260..f9727f8 100644
--- a/sign_csr.py
+++ b/sign_csr.py
@@ -29,6 +29,8 @@ def sign_csr(pubkey, csr):
proc = subprocess.Popen(["openssl", "rsa", "-pubin", "-in", pubkey, "-noout", "-text"],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
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]+)\
@@ -55,6 +57,8 @@ Exponent\: ([0-9]+)\
proc = subprocess.Popen(["openssl", "req", "-in", csr, "-noout", "-text"],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = proc.communicate()
+ if proc.returncode != 0:
+ raise IOError("Error loading {}".format(csr))
domain = re.search("Subject:.*? CN=([^\s,;/]+).*?", out, re.MULTILINE|re.DOTALL).groups()[0]
sys.stderr.write("Found domain '{}'\n".format(domain))