Skip to content

Commit

Permalink
Added get_cert_chain() in configuration.py
Browse files Browse the repository at this point in the history
The get_cert_chain() has been added into configuration.py
to retrieve the signing certificate chain from the CA.
  • Loading branch information
edewata committed Apr 30, 2020
1 parent 2141e8e commit e688337
Showing 1 changed file with 20 additions and 0 deletions.
Expand Up @@ -25,6 +25,7 @@
import logging
import os
import shutil
import subprocess
import tempfile
import urllib.parse

Expand Down Expand Up @@ -526,6 +527,25 @@ def import_perm_sslserver_cert(self, deployer, instance, cert):
nssdb.close()
shutil.rmtree(tmpdir)

def get_cert_chain(self, instance, url):

cmd = [
'pki',
'-d', instance.nssdb_dir,
'-f', instance.password_conf,
'-U', url,
'--ignore-cert-status', 'UNTRUSTED_ISSUER',
'ca-cert-signing-export',
'--pkcs7'
]

logger.debug('Command: %s', ' '.join(cmd))

# TODO: Replace stdout/stderr with capture_output in Python 3.7.
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)

return result.stdout.decode()

def spawn(self, deployer):

external = deployer.configuration_file.external
Expand Down

0 comments on commit e688337

Please sign in to comment.