=pod =head1 NAME PKCS12_create - create a PKCS#12 structure =head1 SYNOPSIS #include PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter, int mac_iter, int keytype); =head1 DESCRIPTION PKCS12_create() creates a PKCS#12 structure. I is the passphrase to use. I is the B to use for the supplied certificate and key. I is the private key to include in the structure and I its corresponding certificates. I, if not NULL is an optional set of certificates to also include in the structure. I and I are the encryption algorithms that should be used for the key and certificate respectively. The modes GCM, CCM, XTS, and OCB are unsupported. I is the encryption algorithm iteration count to use and I is the MAC iteration count to use. I is the type of key. =head1 NOTES The parameters I, I, I, I and I can all be set to zero and sensible defaults will be used. These defaults are: AES password based encryption (PBES2 with PBKDF2 and AES-256-CBC) for private keys and certificates, the PBKDF2 and MAC key derivation iteration count of B (currently 2048), and MAC algorithm HMAC with SHA2-256. I adds a flag to the store private key. This is a non standard extension that is only currently interpreted by MSIE. If set to zero the flag is omitted, if set to B the key can be used for signing only, if set to B it can be used for signing and encryption. This option was useful for old export grade software which could use signing only keys of arbitrary size but had restrictions on the permissible sizes of keys which could be used for encryption. If a certificate contains an I or I then this will be used for the corresponding B or B in the PKCS12 structure. Either I, I or both can be NULL to indicate that no key or certificate is required. In previous versions both had to be present or a fatal error is returned. I or I can be set to -1 indicating that no encryption should be used. I can be set to -1 and the MAC will then be omitted entirely. PKCS12_create() makes assumptions regarding the encoding of the given pass phrase. See L for more information. =head1 RETURN VALUES PKCS12_create() returns a valid B structure or NULL if an error occurred. =head1 SEE ALSO L, L =head1 HISTORY The defaults for encryption algorithms, MAC algorithm, and the MAC key derivation iteration count were changed in OpenSSL 3.0 to more modern standards. =head1 COPYRIGHT Copyright 2002-2021 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 L. =cut