Commit c5ebc91b authored by Boxiang Sun's avatar Boxiang Sun

CertificateAuthorityTool: raise ValueError if have duplicate certificate

parent 4ed6c3f3
...@@ -188,6 +188,15 @@ class CertificateAuthorityTool(BaseTool): ...@@ -188,6 +188,15 @@ class CertificateAuthorityTool(BaseTool):
raise ValueError("Invalid common name: %r" % common_name) raise ValueError("Invalid common name: %r" % common_name)
self._checkCertificateAuthority() self._checkCertificateAuthority()
self._lockCertificateAuthority() self._lockCertificateAuthority()
index = open(self.index).read().splitlines()
valid_line_list = [q for q in index if q.startswith('V') and
('CN=%s/' % common_name in q)]
if len(valid_line_list) >= 1:
self._unlockCertificateAuthority()
raise ValueError('The common name %r already has a certificate'
'please revoke it before request a new one..' % common_name)
try: try:
new_id = open(self.serial, 'r').read().strip().lower() new_id = open(self.serial, 'r').read().strip().lower()
key = os.path.join(self.certificate_authority_path, 'private', key = os.path.join(self.certificate_authority_path, 'private',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment