Skip to content

Commit

Permalink
Consolidate SystemCertData.token initialization
Browse files Browse the repository at this point in the history
The code that initializes SystemCertData.token has been
consolidated into PKIDeployer.create_system_cert_info().
  • Loading branch information
edewata committed Aug 10, 2023
1 parent 3723b0c commit e620ae7
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions base/server/python/pki/server/deployment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,6 @@ def init_server_nssdb(self, subsystem):

instance = subsystem.instance

if config.str2bool(self.mdict['pki_hsm_enable']):
hsm_token = self.mdict['pki_token_name']
subsystem.config['preop.module.token'] = hsm_token

# Since 'certutil' does NOT strip the 'token=' portion of
# the 'token=password' entries, create a temporary server 'pfile'
# which ONLY contains the 'password' for the purposes of
Expand Down Expand Up @@ -2668,6 +2664,15 @@ def create_system_cert_info(self, subsystem, tag):
system_cert.subjectDN = self.mdict['pki_%s_subject_dn' % cert_id]
system_cert.token = self.mdict['pki_%s_token' % cert_id]

if not system_cert.token:
if config.str2bool(self.mdict['pki_hsm_enable']):
system_cert.token = self.mdict['pki_token_name']
else:
system_cert.token = subsystem.config['preop.module.token']

if not pki.nssdb.normalize_token(system_cert.token):
system_cert.token = pki.nssdb.INTERNAL_TOKEN_NAME

return system_cert

def create_cert_setup_request(self, subsystem, tag, cert):
Expand All @@ -2678,12 +2683,6 @@ def create_cert_setup_request(self, subsystem, tag, cert):

request.systemCert = self.create_system_cert_info(subsystem, tag)

if not request.systemCert.token:
request.systemCert.token = subsystem.config['preop.module.token']

if not pki.nssdb.normalize_token(request.systemCert.token):
request.systemCert.token = pki.nssdb.INTERNAL_TOKEN_NAME

# cert type: selfsign, local, or remote
request.systemCert.type = subsystem.config['preop.cert.%s.type' % tag]

Expand Down

0 comments on commit e620ae7

Please sign in to comment.