Skip to content

Commit

Permalink
Remove unused Certutil class
Browse files Browse the repository at this point in the history
  • Loading branch information
edewata committed Sep 25, 2024
1 parent 318c1b4 commit 1e2c26e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 76 deletions.
2 changes: 0 additions & 2 deletions base/server/python/pki/server/deployment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def __init__(self):
self.war = None
self.password = None
self.hsm = None
self.certutil = None
self.kra_connector = None
self.systemd = None
self.tps_connector = None
Expand Down Expand Up @@ -189,7 +188,6 @@ def init(self):
self.configuration_file = util.ConfigurationFile(self)
self.password = util.Password(self)
self.hsm = util.HSM(self)
self.certutil = util.Certutil(self)
self.kra_connector = util.KRAConnector(self)
self.systemd = util.Systemd(self)
self.tps_connector = util.TPSConnector(self)
Expand Down
74 changes: 0 additions & 74 deletions base/server/python/pki/server/deployment/pkihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,80 +741,6 @@ def restart_ncipher(self, critical_failure=True):
return


class Certutil:
"""PKI Deployment NSS 'certutil' Class"""

def __init__(self, deployer):
self.mdict = deployer.mdict
self.nss_db_type = deployer.nss_db_type

def _get_dbfiles(self, path):
if self.nss_db_type == 'sql':
filenames = ['cert9.db', 'key4.db', 'pkcs11.txt']
elif self.nss_db_type == 'dbm':
filenames = ['cert8.db', 'key3.db', 'secmod.db']
else:
raise ValueError(self.nss_db_type)
return [os.path.join(path, filename) for filename in filenames]

def create_security_databases(self, path,
password_file=None, prefix=None,
critical_failure=True):

logger.info('Creating %s', path)

cert_db, key_db, secmod_db = self._get_dbfiles(path)
try:
# Compose this "certutil" command
command = ["certutil", "-N"]
# Provide a path to the NSS security databases
if path:
command.extend(["-d", path])
else:
logger.error(log.PKIHELPER_CERTUTIL_MISSING_PATH)
raise Exception(log.PKIHELPER_CERTUTIL_MISSING_PATH)
if password_file is not None:
command.extend(["-f", password_file])
if prefix is not None:
command.extend(["-P", prefix])
if not os.path.exists(path):
logger.error(log.PKI_DIRECTORY_MISSING_OR_NOT_A_DIRECTORY_1, path)
raise Exception(
log.PKI_DIRECTORY_MISSING_OR_NOT_A_DIRECTORY_1 % path)
if os.path.exists(cert_db) or\
os.path.exists(key_db) or\
os.path.exists(secmod_db):
# Simply notify user that the security databases exist
logger.info(
log.PKI_SECURITY_DATABASES_ALREADY_EXIST_3,
cert_db,
key_db,
secmod_db)
else:
if password_file is not None:
if not os.path.exists(password_file) or\
not os.path.isfile(password_file):
logger.error(
log.PKI_FILE_MISSING_OR_NOT_A_FILE_1,
password_file)
raise Exception(
log.PKI_FILE_MISSING_OR_NOT_A_FILE_1 %
password_file)

logger.debug('Command: %s', ' '.join(command))
subprocess.check_call(command)

except subprocess.CalledProcessError as exc:
logger.error(log.PKI_SUBPROCESS_ERROR_1, exc)
if critical_failure:
raise
except OSError as exc:
logger.error(log.PKI_OSERROR_1, exc)
if critical_failure:
raise
return


class KRAConnector:
"""PKI Deployment KRA Connector Class"""

Expand Down

0 comments on commit 1e2c26e

Please sign in to comment.