conf='conf/ca.conf',
public_key='public/ca.pem',
private_key='private/ca.key',
- crl='public/crl.pem',
+ crl='public/ca.crl',
serial='serial',
crlnumber='crlnumber',
index='index')
fcntl.lockf(self._lockfd, fcntl.LOCK_UN)
self._lockfd.close()
+ def _update_config(self):
+ # Create the OpenSSL configuration file.
+ utils.render(self.files.conf, 'openssl_config', self.config)
+
def close(self):
self._unlock()
with open(self.files.crlnumber, 'w') as fd:
fd.write('01\n')
- # Create the OpenSSL configuration file.
- utils.render(self.files.conf, 'openssl_config', self.config)
+ self._update_config()
# Generate keys if they do not exist.
if not os.path.exists(self.files.public_key):
def gencrl(self):
log.info('generating CRL')
+
+ self._update_config()
+
+ # Write the CRL in PEM format to a temporary file.
+ tmpf = self.files.crl + '.tmp'
openssl_wrap.run_with_config(
self.basedir, self.files.conf,
- 'ca', '-gencrl', '-out', self.files.crl,
+ 'ca', '-gencrl', '-out', tmpf,
'-key', self._getpw())
+ # Convert to DER format for distribution.
+ openssl_wrap.run(
+ 'crl', '-inform', 'PEM', '-outform', 'DER',
+ '-in', tmpf, '-out', self.files.crl)
+ os.remove(tmpf)
os.chmod(self.files.crl, 0644)
def revoke(self, cert):
self.gencrl()
def generate(self, cert):
+ self._update_config()
+
expiry = cert.get_expiration_date()
if expiry and expiry > time.time():
log.warn('certificate is still valid, revoking previous version')