Merge pull request #3211 from charhate/ecc_changes
Modify description during reissue
This commit is contained in:
commit
ff83721720
|
@ -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
|
||||||
|
@ -779,6 +780,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
|
||||||
|
|
|
@ -802,6 +802,7 @@ def test_reissue_certificate(
|
||||||
assert new_cert.organization != certificate.organization
|
assert new_cert.organization != certificate.organization
|
||||||
# Check for default value since authority does not have cab_compliant option set
|
# Check for default value since authority does not have cab_compliant option set
|
||||||
assert new_cert.organization == LEMUR_DEFAULT_ORGANIZATION
|
assert new_cert.organization == LEMUR_DEFAULT_ORGANIZATION
|
||||||
|
assert new_cert.description.startswith(f"Reissued by Lemur for cert ID {certificate.id}")
|
||||||
|
|
||||||
# update cab_compliant option to false for crypto_authority to maintain subject details
|
# update cab_compliant option to false for crypto_authority to maintain subject details
|
||||||
update_options(crypto_authority.id, '[{"name": "cab_compliant","value":false}]')
|
update_options(crypto_authority.id, '[{"name": "cab_compliant","value":false}]')
|
||||||
|
|
Loading…
Reference in New Issue