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