Skip to content

Commit

Permalink
fix pkcs12 parse ordering. fixes pyca#5872 (pyca#5879)
Browse files Browse the repository at this point in the history
* fix pkcs12 parse ordering. fixes pyca#5872

* remove an unneeded print

* simplify the test a bit more

* index

* black

* Update tests/hazmat/primitives/test_pkcs12.py

Co-authored-by: Alex Gaynor <[email protected]>

Co-authored-by: Alex Gaynor <[email protected]>
  • Loading branch information
2 people authored and vishwin committed Dec 24, 2022
1 parent ac5359d commit 82cbacf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/cryptography/hazmat/backends/openssl/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2638,9 +2638,7 @@ def serialize_key_and_certificates_to_pkcs12(
sk_x509 = self._lib.sk_X509_new_null()
sk_x509 = self._ffi.gc(sk_x509, self._lib.sk_X509_free)

# reverse the list when building the stack so that they're encoded
# in the order they were originally provided. it is a mystery
for ca in reversed(cas):
for ca in cas:
res = self._lib.sk_X509_push(sk_x509, ca._x509)
backend.openssl_assert(res >= 1)

Expand Down
4 changes: 3 additions & 1 deletion tests/hazmat/primitives/test_pkcs12.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@


import os
from datetime import datetime

import pytest

from cryptography import x509
from cryptography.hazmat.backends.interfaces import DERSerializationBackend
from cryptography.hazmat.backends.openssl.backend import _RC2
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives.serialization import load_pem_private_key
from cryptography.hazmat.primitives.serialization.pkcs12 import (
load_key_and_certificates,
Expand Down

0 comments on commit 82cbacf

Please sign in to comment.