openssl_pkcs12: fix crash when trying to get non-existing other certificates (#487)

* Fix crash when trying to get non-existing other certificates.

* Add test.
This commit is contained in:
Felix Fontein
2022-07-07 22:30:22 +02:00
committed by GitHub
parent b16f12faa3
commit 9ed4526fee
4 changed files with 17 additions and 0 deletions

View File

@@ -559,6 +559,8 @@ class PkcsPyOpenSSL(Pkcs):
return crypto.dump_certificate(crypto.FILETYPE_PEM, cert) if cert else None
def _dump_other_certificates(self, pkcs12):
if pkcs12.get_ca_certificates() is None:
return []
return [
crypto.dump_certificate(crypto.FILETYPE_PEM, other_cert)
for other_cert in pkcs12.get_ca_certificates()