use M2Crypto for parse function

This commit is contained in:
Eric Wustrow
2012-07-12 19:10:54 -04:00
parent 1bb0fc7286
commit 1c129ea1d7
+14 -5
View File
@@ -8,11 +8,20 @@ import M2Crypto
# to pass to OpenSSL subprocesses.
def parse(csr):
"""Is this CSR syntactically valid?"""
out, err = subprocess.Popen(["openssl", "req", "-noout"],shell=False,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate(csr)
if not err:
return True
return False
"""
Is this CSR syntactically valid? (TODO: remove)
@type csr: str
@param csr: PEM-encoded string of the CSR.
@return: True if M2Crypto can parse the csr,
False if there is an error parsing it.
"""
try:
req = M2Crypto.X509.load_request_string(csr)
return True
except Exception:
return False
def modulusbits(key):
"""How many bits are in the modulus of this key?"""