1PKCS12_PARSE(3ossl) OpenSSL PKCS12_PARSE(3ossl)
2
3
4
6 PKCS12_parse - parse a PKCS#12 structure
7
9 #include <openssl/pkcs12.h>
10
11 int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
12 STACK_OF(X509) **ca);
13
15 PKCS12_parse() parses a PKCS12 structure.
16
17 p12 is the PKCS12 structure to parse. pass is the passphrase to use.
18 If successful the private key will be written to *pkey, the
19 corresponding certificate to *cert and any additional certificates to
20 *ca.
21
23 Each of the parameters pkey, cert, and ca can be NULL in which case the
24 private key, the corresponding certificate, or the additional
25 certificates, respectively, will be discarded. If any of pkey and cert
26 is non-NULL the variable it points to is initialized. If ca is non-
27 NULL and *ca is NULL a new STACK will be allocated. If ca is non-NULL
28 and *ca is a valid STACK then additional certificates are appended in
29 the given order to *ca.
30
31 The friendlyName and localKeyID attributes (if present) on each
32 certificate will be stored in the alias and keyid attributes of the
33 X509 structure.
34
35 The parameter pass is interpreted as a string in the UTF-8 encoding. If
36 it is not valid UTF-8, then it is assumed to be ISO8859-1 instead.
37
38 In particular, this means that passwords in the locale character set
39 (or code page on Windows) must potentially be converted to UTF-8 before
40 use. This may include passwords from local text files, or input from
41 the terminal or command line. Refer to the documentation of
42 UI_OpenSSL(3), for example.
43
45 PKCS12_parse() returns 1 for success and zero if an error occurred.
46
47 The error can be obtained from ERR_get_error(3)
48
50 Only a single private key and corresponding certificate is returned by
51 this function. More complex PKCS#12 files with multiple private keys
52 will only return the first match.
53
54 Only friendlyName and localKeyID attributes are currently stored in
55 certificates. Other attributes are discarded.
56
57 Attributes currently cannot be stored in the private key EVP_PKEY
58 structure.
59
61 d2i_PKCS12(3), passphrase-encoding(7)
62
64 Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
65
66 Licensed under the Apache License 2.0 (the "License"). You may not use
67 this file except in compliance with the License. You can obtain a copy
68 in the file LICENSE in the source distribution or at
69 <https://www.openssl.org/source/license.html>.
70
71
72
733.0.5 2022-11-01 PKCS12_PARSE(3ossl)