mirror of
https://github.com/ansible-collections/community.crypto.git
synced 2026-05-06 21:33:00 +00:00
Fix openssl_pkcs12 crash with cryptography backend when loading passphrase-protected files (#248)
* Convert passphrase to bytes when loading PKCS#12 file with cryptography. * Add tests with PKCS#12 passphrase. * Add changelog fragment.
This commit is contained in:
@@ -23,7 +23,7 @@ import base64
|
||||
import binascii
|
||||
import re
|
||||
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible.module_utils._text import to_text, to_bytes
|
||||
from ._asn1 import serialize_asn1_string_as_der
|
||||
|
||||
try:
|
||||
@@ -444,7 +444,8 @@ def parse_pkcs12(pkcs12_bytes, passphrase=None):
|
||||
'''
|
||||
if _load_key_and_certificates is None:
|
||||
raise ValueError('load_key_and_certificates() not present in the current cryptography version')
|
||||
private_key, certificate, additional_certificates = _load_key_and_certificates(pkcs12_bytes, passphrase)
|
||||
private_key, certificate, additional_certificates = _load_key_and_certificates(
|
||||
pkcs12_bytes, to_bytes(passphrase) if passphrase is not None else None)
|
||||
|
||||
friendly_name = None
|
||||
if certificate:
|
||||
|
||||
Reference in New Issue
Block a user