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

Get the intermediate certificate whenever needed #64

Merged
Merged
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
18 changes: 8 additions & 10 deletions lecm/certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,15 @@ def _create_filesystem(self):
utils.enforce_selinux_context(self.path)

def _get_intermediate_certificate(self):
certificate = requests.get(_INTERMEDIATE_CERTIFICATE_URL).text
certificate_name = os.path.basename(_INTERMEDIATE_CERTIFICATE_URL)

LOG.info('[global] Getting intermediate certificate PEM file: %s' %
certificate_name)
if not os.path.exists('%s/pem/%s' % (self.path, certificate_name)):
with open('%s/pem/%s' % (self.path, certificate_name), 'w') as f:
f.write(certificate)
certificate = requests.get(_INTERMEDIATE_CERTIFICATE_URL).text

LOG.info('[global] Getting intermediate certificate PEM file: %s' %
certificate_name)
if not os.path.exists('%s/pem/%s' % (self.path, certificate_name)):
with open('%s/pem/%s' % (self.path, certificate_name), 'w') as f:
f.write(certificate)

def _create_account_key(self):
account_key = crypto.PKey()
Expand Down Expand Up @@ -257,6 +258,7 @@ def _create_certificate(self):

LOG.debug('[%s] Concatenating certificate with intermediate pem: \
%s/pem/%s.pem' % (self.name, self.path, self.name))
self._get_intermediate_certificate()
pem_filename = os.path.basename(_INTERMEDIATE_CERTIFICATE_URL)
filenames = ['%s/certs/%s.crt' % (self.path, self.name),
'%s/pem/%s' % (self.path, pem_filename)]
Expand Down Expand Up @@ -287,10 +289,6 @@ def generate(self):

self._create_filesystem()

certificate_name = os.path.basename(_INTERMEDIATE_CERTIFICATE_URL)
if not os.path.exists('%s/pem/%s' % (self.path, certificate_name)):
self._get_intermediate_certificate()

# Ensure there is no left-over from previous setup
#
try:
Expand Down