PKCS12_parse.pod 2.5 KB

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