Modify description during reissue
Include the certificate ID being reissued and mention that this is created by Lemur as part of reissue
This commit is contained in:
parent
d58b32a19c
commit
2c22d42a57
|
@ -6,6 +6,7 @@
|
||||||
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
|
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
|
||||||
"""
|
"""
|
||||||
import arrow
|
import arrow
|
||||||
|
import re
|
||||||
from cryptography import x509
|
from cryptography import x509
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
from cryptography.hazmat.primitives import hashes, serialization
|
from cryptography.hazmat.primitives import hashes, serialization
|
||||||
|
@ -778,6 +779,19 @@ def reissue_certificate(certificate, replace=None, user=None):
|
||||||
if replace:
|
if replace:
|
||||||
primitives["replaces"] = [certificate]
|
primitives["replaces"] = [certificate]
|
||||||
|
|
||||||
|
# Modify description to include the certificate ID being reissued and mention that this is created by Lemur
|
||||||
|
# as part of reissue
|
||||||
|
reissue_message_prefix = "Reissued by Lemur for cert ID "
|
||||||
|
reissue_message = re.compile(f"{reissue_message_prefix}([0-9]+)")
|
||||||
|
if primitives["description"]:
|
||||||
|
match = reissue_message.search(primitives["description"])
|
||||||
|
if match:
|
||||||
|
primitives["description"] = primitives["description"].replace(match.group(1), str(certificate.id))
|
||||||
|
else:
|
||||||
|
primitives["description"] = f"{reissue_message_prefix}{certificate.id}, {primitives['description']}"
|
||||||
|
else:
|
||||||
|
primitives["description"] = f"{reissue_message_prefix}{certificate.id}"
|
||||||
|
|
||||||
new_cert = create(**primitives)
|
new_cert = create(**primitives)
|
||||||
|
|
||||||
return new_cert
|
return new_cert
|
||||||
|
|
Loading…
Reference in New Issue