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

chore(deps): Bump cryptography from 42.0.8 to 43.0.1 #693

Merged
merged 2 commits into from
Sep 24, 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 requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ colorama==0.4.6
# via tox
coverage==7.6.1
# via -r requirements-dev.in
cryptography==42.0.8
cryptography==43.0.1
# via
# -c requirements.txt
# secretstorage
Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# git+https://github.com/example/example.git@example-vcs-ref#egg=example-pkg[foo,bar]==1.42.3

backports-zoneinfo==0.2.1 ; python_version < "3.9" # Used by `djangorestframework`.
cryptography==42.0.8
cryptography==43.0.1
defusedxml==0.7.1
django-filter>=24.2
Django>=2.2.24
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ certifi==2024.7.4
# via signxml
cffi==1.16.0
# via cryptography
cryptography==42.0.8
cryptography==43.0.1
# via
# -r requirements.in
# pyopenssl
Expand Down
4 changes: 3 additions & 1 deletion src/cl_sii/rut/crypto_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import cryptography
import cryptography.x509
from cryptography.hazmat.backends.openssl import backend as crypto_x509_backend
from cryptography.hazmat.primitives.serialization import pkcs12

from . import Rut, constants

Expand All @@ -21,9 +22,10 @@ def get_subject_rut_from_certificate_pfx(pfx_file_bytes: bytes, password: Option
private_key,
x509_cert,
additional_certs,
) = crypto_x509_backend.load_key_and_certificates_from_pkcs12(
) = pkcs12.load_key_and_certificates(
data=pfx_file_bytes,
password=password.encode() if password is not None else None,
backend=crypto_x509_backend,
)
# https://cryptography.io/en/latest/hazmat/primitives/asymmetric/serialization/#cryptography.hazmat.primitives.serialization.pkcs12.load_key_and_certificates # noqa: E501

Expand Down
5 changes: 3 additions & 2 deletions src/tests/test_libs_crypto_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,8 @@ def test_load_der_x509_cert_fail_value_error(self) -> None:
with self.assertRaises(ValueError) as cm:
load_der_x509_cert(b'hello')
self.assertEqual(
cm.exception.args, ("error parsing asn1 value: ParseError { kind: ShortData }",)
cm.exception.args,
("error parsing asn1 value: ParseError { kind: ShortData { needed: 98 } }",),
)

def test_load_pem_x509_cert_ok(self) -> None:
Expand Down Expand Up @@ -1004,7 +1005,7 @@ def test_load_pem_x509_cert_fail_value_error(self) -> None:
(
"Unable to load PEM file. See "
"https://cryptography.io/en/latest/faq/#why-can-t-i-import-my-pem-file "
"for more details. InvalidData(InvalidLength)",
"for more details. InvalidData(InvalidLength(5))",
),
)

Expand Down
14 changes: 7 additions & 7 deletions src/tests/test_rut_crypto_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from unittest.mock import Mock, patch

import cryptography.x509
from cryptography.hazmat.backends.openssl import backend as crypto_x509_backend
from cryptography.hazmat.primitives.serialization import pkcs12

from cl_sii import rut
from cl_sii.libs.crypto_utils import load_der_x509_cert
Expand All @@ -19,8 +19,8 @@ def test_get_subject_rut_from_certificate_pfx_ok(self) -> None:
x509_cert = load_der_x509_cert(cert_der_bytes)

with patch.object(
crypto_x509_backend,
'load_key_and_certificates_from_pkcs12',
pkcs12,
'load_key_and_certificates',
Mock(return_value=(None, x509_cert, None)),
):
pfx_file_bytes = b'hello'
Expand All @@ -40,8 +40,8 @@ def test_get_subject_rut_from_certificate_pfx_fails_if_rut_info_is_missing(self)
x509_cert = load_der_x509_cert(cert_der_bytes)

with patch.object(
crypto_x509_backend,
'load_key_and_certificates_from_pkcs12',
pkcs12,
'load_key_and_certificates',
Mock(return_value=(None, x509_cert, None)),
):
pfx_file_bytes = b'hello'
Expand Down Expand Up @@ -81,8 +81,8 @@ def test_get_subject_rut_from_certificate_pfx_does_not_throw_attribute_error_if_
)

with patch.object(
crypto_x509_backend,
'load_key_and_certificates_from_pkcs12',
pkcs12,
'load_key_and_certificates',
Mock(return_value=(None, x509_cert, None)),
), patch.object(
x509_cert.extensions,
Expand Down