Skip to content

Commit

Permalink
make regex more broad when searching for DH and EC params
Browse files Browse the repository at this point in the history
  • Loading branch information
plinss committed Nov 7, 2018
1 parent d9535db commit 5ad5ec6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions acmebot
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class AcmeManager(object):
def __init__(self):
self.script_dir = os.path.dirname(os.path.realpath(__file__))
self.script_name = os.path.basename(__file__)
self.script_version = '2.2.1'
self.script_version = '2.2.2'

self._color_codes = {
'black': 30,
Expand Down Expand Up @@ -1184,7 +1184,7 @@ class AcmeManager(object):
if (dhparam_pem):
try:
output = subprocess.check_output(['openssl', 'dhparam', '-text'], input=dhparam_pem.encode('ascii'), stderr=subprocess.DEVNULL)
match = re.match(r'\s*DH Parameters: \(([0-9]+) bit\)\n', output.decode('ascii'))
match = re.search(r'DH Parameters: \(([0-9]+) bit\)', output.decode('ascii'))
if (match):
return int(match.group(1))
except Exception:
Expand All @@ -1195,7 +1195,7 @@ class AcmeManager(object):
if (ecparam_pem):
try:
output = subprocess.check_output(['openssl', 'ecparam', '-text'], input=ecparam_pem.encode('ascii'), stderr=subprocess.DEVNULL)
match = re.match(r'ASN1 OID: ([^\s]+)\n', output.decode('ascii'))
match = re.search(r'ASN1 OID: ([^\s]+)\n', output.decode('ascii'))
if (match):
return match.group(1)
except Exception:
Expand All @@ -1218,9 +1218,9 @@ class AcmeManager(object):
pem_data = certificate_file.read()
break
if (pem_data):
match = re.match(r'.*(-----BEGIN DH PARAMETERS-----.*-----END DH PARAMETERS-----)', pem_data, re.DOTALL)
match = re.search(r'(-----BEGIN DH PARAMETERS-----.*-----END DH PARAMETERS-----)', pem_data, re.DOTALL)
dhparam_pem = (match.group(1) + '\n') if (match) else None
match = re.match(r'.*(-----BEGIN EC PARAMETERS-----.*-----END EC PARAMETERS-----)', pem_data, re.DOTALL)
match = re.search(r'(-----BEGIN EC PARAMETERS-----.*-----END EC PARAMETERS-----)', pem_data, re.DOTALL)
ecparam_pem = (match.group(1) + '\n') if (match) else None
if (not self.check_dhparam(dhparam_pem)):
dhparam_pem = None
Expand Down Expand Up @@ -2200,6 +2200,7 @@ class AcmeManager(object):
passphrase=key_cipher_data.passphrase if (key_cipher_data) else None)
except PrivateKeyError as error:
self._warn('Unable to encrypt private key ', error, '\n')
self._clear_hooks()
continue

# verify and generate hpkp headers
Expand Down

0 comments on commit 5ad5ec6

Please sign in to comment.