Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.0][FIX] Make letsencrypt resilient for alternate name removal. #757

Merged
merged 3 commits into from
Apr 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions letsencrypt/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ Contributors
* Holger Brunn <hbrunn@therp.nl>
* Antonio Espinosa <antonio.espinosa@tecnativa.com>
* Dave Lasley <dave@laslabs.com>
* Ronald Portier <ronald@therp.nl>

ACME implementation
-------------------
Expand Down
27 changes: 12 additions & 15 deletions letsencrypt/models/letsencrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,10 @@ def call_cmdline(self, cmdline, loglevel=logging.INFO,
_logger.log(loglevel, stderr)
if stdout:
_logger.log(loglevel, stdout)

if process.returncode:
raise exceptions.Warning(
_('Error calling %s: %d') % (cmdline[0], process.returncode),
' '.join(cmdline),
_('Error calling %s: %d') % (cmdline[0], process.returncode)
)

return process.returncode

@api.model
Expand Down Expand Up @@ -96,19 +93,19 @@ def _ip_is_private(address):
@api.model
def generate_csr(self, domain):
domains = [domain]
i = 0
while self.env['ir.config_parameter'].get_param(
'letsencrypt.altname.%d' % i):
domains.append(
self.env['ir.config_parameter']
.get_param('letsencrypt.altname.%d' % i)
)
i += 1
parameter_model = self.env['ir.config_parameter']
altnames = parameter_model.search(
[('key', 'like', 'letsencrypt.altname.')],
order='key'
)
for altname in altnames:
domains.append(altname.value)
_logger.info('generating csr for %s', domain)
if len(domains) > 1:
_logger.info('with alternative subjects %s', ','.join(domains[1:]))
config = self.env['ir.config_parameter'].get_param(
'letsencrypt.openssl.cnf', '/etc/ssl/openssl.cnf')
config = parameter_model.get_param(
'letsencrypt.openssl.cnf', '/etc/ssl/openssl.cnf'
)
csr = os.path.join(get_data_dir(), '%s.csr' % domain)
with tempfile.NamedTemporaryFile() as cfg:
cfg.write(open(config).read())
Expand All @@ -119,7 +116,7 @@ def generate_csr(self, domain):
cfg.file.flush()
cmdline = [
'openssl', 'req', '-new',
self.env['ir.config_parameter'].get_param(
parameter_model.get_param(
'letsencrypt.openssl.digest', '-sha256'),
'-key', self.generate_domain_key(domain),
'-subj', '/CN=%s' % domain, '-config', cfg.name,
Expand Down