File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 1+ Add the Authority Key Identifier extension to child CA certificates.
Original file line number Diff line number Diff line change @@ -246,18 +246,27 @@ def __init__(
246246 )
247247 issuer = name
248248 sign_key = self ._private_key
249+ aki : Optional [x509 .AuthorityKeyIdentifier ]
249250 if parent_cert is not None :
250251 sign_key = parent_cert ._private_key
251252 parent_certificate = parent_cert ._certificate
252253 issuer = parent_certificate .subject
253-
254- self ._certificate = (
254+ ski_ext = parent_certificate .extensions .get_extension_for_class (
255+ x509 .SubjectKeyIdentifier )
256+ aki = x509 .AuthorityKeyIdentifier .from_issuer_subject_key_identifier (ski_ext .value )
257+ else :
258+ aki = None
259+ cert_builder = (
255260 _cert_builder_common (name , issuer , self ._private_key .public_key ())
256261 .add_extension (
257262 x509 .BasicConstraints (ca = True , path_length = path_length ),
258263 critical = True ,
259264 )
260- .add_extension (
265+ )
266+ if aki :
267+ cert_builder = cert_builder .add_extension (aki , critical = False )
268+ self ._certificate = (
269+ cert_builder .add_extension (
261270 x509 .KeyUsage (
262271 digital_signature = True , # OCSP
263272 content_commitment = False ,
Original file line number Diff line number Diff line change @@ -200,6 +200,11 @@ def test_intermediate() -> None:
200200 assert_is_ca (child_ca_cert )
201201 assert child_ca_cert .issuer == ca_cert .subject
202202 assert _path_length (child_ca_cert ) == 8
203+ aki = child_ca_cert .extensions .get_extension_for_class (x509 .AuthorityKeyIdentifier )
204+ assert aki .critical is False
205+ expected_aki_key_id = ca_cert .extensions .get_extension_for_class (
206+ x509 .SubjectKeyIdentifier ).value .digest
207+ assert aki .value .key_identifier == expected_aki_key_id
203208
204209 child_server = child_ca .issue_cert ("test-host.example.org" )
205210 assert len (child_server .cert_chain_pems ) == 2
You can’t perform that action at this time.
0 commit comments