PKCS12_parse(): Fix reversed order of certs parsed and output via *ca
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Wed, 12 Aug 2020 16:06:00 +0000 (18:06 +0200)
committerDr. David von Oheimb <David.von.Oheimb@siemens.com>
Wed, 19 Aug 2020 07:50:21 +0000 (09:50 +0200)
Fixes #6698

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12641)

CHANGES.md
crypto/pkcs12/p12_kiss.c

index 3ecdd5d99bbd65695d40fd65ca4e8826cd938cf1..31e183f3959d848327234e0f2b149d3bebdfe110 100644 (file)
@@ -1172,6 +1172,11 @@ OpenSSL 3.0
 
    *Martin Elshuber*
 
+ * `PKCS12_parse` now maintains the order of the parsed certificates
+   when outputting them via `*ca` (rather than reversing it).
+
+   *David von Oheimb*
+
 OpenSSL 1.1.1
 -------------
 
index eaf6501c1c9eec5ecac3d47b1a8d2ce465b995e1..4cbf4530ffbe5f40a1499a7d4496ac3f55a56a3e 100644 (file)
@@ -89,7 +89,7 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
         goto err;
     }
 
-    while ((x = sk_X509_pop(ocerts))) {
+    while ((x = sk_X509_shift(ocerts))) {
         if (pkey != NULL && *pkey != NULL
                 && cert != NULL && *cert == NULL) {
             ERR_set_mark();