PKCS12_PARSE(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’– PKCS12_PARSE(3ossl) πŸ’–

okay so bestie, welcome to the OpenSSL manual page for PKCS12_PARSE(3ossl) β€” this one is all about pulling the goodies out of a PKCS#12 structure, and yes, we’re gonna keep every tiny detail because we don’t skip lore. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <openssl/pkcs12.h>

int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
                 STACK_OF(X509) **ca);

🌸 DESCRIPTION 🌸

PKCS12_parse() parses a PKCS12 structure. iconic behavior, honestly.

p12 is the PKCS12 structure to parse. pass is the passphrase to use. If it works, the private key gets written to *pkey, the corresponding certificate gets written to *cert, and any additional certificates get written to *ca. slay ✨


✨ NOTES ✨

Each of the parameters pkey, cert, and ca can be NULL. In that case, the private key, the corresponding certificate, or the additional certificates, respectively, will be discarded. gone, but make it intentional.

If any of pkey and cert is non-NULL, the variable it points to is initialized. If ca is non-NULL and *ca is NULL, a new STACK will be allocated. If ca is non-NULL and *ca is a valid STACK, then additional certificates are appended in the given order to *ca.

The friendlyName and localKeyID attributes (if present) on each certificate will be stored in the alias and keyid attributes of the X509 structure. cute little metadata moment πŸŽ€

The parameter pass is interpreted as a string in the UTF-8 encoding. If it is not valid UTF-8, then it is assumed to be ISO8859-1 instead. encoding check, bestie 🫢

In particular, this means that passwords in the locale character set (or code page on Windows) must potentially be converted to UTF-8 before use. This may include passwords from local text files, or input from the terminal or command line. Refer to the documentation of UI_OpenSSL(3), for example. iykyk πŸ’–


πŸ”₯ RETURN VALUES πŸ”₯

PKCS12_parse() returns 1 for success and zero if an error occurred.

The error can be obtained from ERR_get_error(3).

bestie, if it’s not 1, go get the error and read it β€” don’t just stare at the screen like it’s gonna explain itself 😭

πŸ’€ BUGS πŸ’€

  • Only a single private key and corresponding certificate is returned by this function. More complex PKCS#12 files with multiple private keys will only return the first match. first match gets the crown, the rest are lowkey left on read πŸ‘‘
  • Only friendlyName and localKeyID attributes are currently stored in certificates. Other attributes are discarded.
  • Attributes currently cannot be stored in the private key EVP_PKEY structure.
this is the β€œknown limits” section, so pls don’t come for the function when it does exactly what it says here πŸ’€

πŸ¦‹ SEE ALSO πŸ¦‹


Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


xoxo, from the OpenSSL 3.5.0 man page drop, dated 2026-09-25 πŸ’–βœ¨

πŸ“¦ where this page comes from