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

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

* Add test.

(cherry picked from commit 9ed4526fee)
This commit is contained in:
Felix Fontein
2022-07-07 22:53:36 +02:00
committed by GitHub
parent 33703d15e2
commit 1df51621fa
4 changed files with 17 additions and 0 deletions

View File

@@ -542,6 +542,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()