Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump black from 24.2.0 to 24.4.2 #646

Merged
merged 2 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lint-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# pip-compile lint-requirements.in
#
black==24.2.0
black==24.4.2
# via -r lint-requirements.in
cffi==1.16.0
# via cryptography
Expand Down
53 changes: 26 additions & 27 deletions src/trustme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,38 +256,37 @@ def __init__(
parent_certificate = parent_cert._certificate
issuer = parent_certificate.subject
ski_ext = parent_certificate.extensions.get_extension_for_class(
x509.SubjectKeyIdentifier)
aki = x509.AuthorityKeyIdentifier.from_issuer_subject_key_identifier(ski_ext.value)
x509.SubjectKeyIdentifier
)
aki = x509.AuthorityKeyIdentifier.from_issuer_subject_key_identifier(
ski_ext.value
)
else:
aki = None
cert_builder = (
_cert_builder_common(name, issuer, self._private_key.public_key())
.add_extension(
x509.BasicConstraints(ca=True, path_length=path_length),
critical=True,
)
cert_builder = _cert_builder_common(
name, issuer, self._private_key.public_key()
).add_extension(
x509.BasicConstraints(ca=True, path_length=path_length),
critical=True,
)
if aki:
cert_builder = cert_builder.add_extension(aki, critical=False)
self._certificate = (
cert_builder.add_extension(
x509.KeyUsage(
digital_signature=True, # OCSP
content_commitment=False,
key_encipherment=False,
data_encipherment=False,
key_agreement=False,
key_cert_sign=True, # sign certs
crl_sign=True, # sign revocation lists
encipher_only=False,
decipher_only=False,
),
critical=True,
)
.sign(
private_key=sign_key,
algorithm=hashes.SHA256(),
)
self._certificate = cert_builder.add_extension(
x509.KeyUsage(
digital_signature=True, # OCSP
content_commitment=False,
key_encipherment=False,
data_encipherment=False,
key_agreement=False,
key_cert_sign=True, # sign certs
crl_sign=True, # sign revocation lists
encipher_only=False,
decipher_only=False,
),
critical=True,
).sign(
private_key=sign_key,
algorithm=hashes.SHA256(),
)

@property
Expand Down
3 changes: 2 additions & 1 deletion tests/test_trustme.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ def test_intermediate() -> None:
aki = child_ca_cert.extensions.get_extension_for_class(x509.AuthorityKeyIdentifier)
assert aki.critical is False
expected_aki_key_id = ca_cert.extensions.get_extension_for_class(
x509.SubjectKeyIdentifier).value.digest
x509.SubjectKeyIdentifier
).value.digest
assert aki.value.key_identifier == expected_aki_key_id

child_server = child_ca.issue_cert("test-host.example.org")
Expand Down
Loading