Commit bdd73044 authored by Boxiang Sun's avatar Boxiang Sun

CertificateAuthorityTool: raise ValueError if have duplicate certificate

parent f3c57d2d
......@@ -186,6 +186,13 @@ class CertificateAuthorityTool(BaseTool):
# {key, certificate, id, common_name}
if not common_name:
raise ValueError("Invalid common name: %r" % common_name)
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:
raise ValueError('The common name %r already has a certificate'
'please revoke it before request a new one..' % common_name)
self._checkCertificateAuthority()
self._lockCertificateAuthority()
try:
......
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