Blame doc/functions/gnutls_pkcs12_simple_parse

Packit aea12f
Packit aea12f
Packit aea12f
Packit aea12f
Packit aea12f
@deftypefun {int} {gnutls_pkcs12_simple_parse} (gnutls_pkcs12_t @var{p12}, const char * @var{password}, gnutls_x509_privkey_t * @var{key}, gnutls_x509_crt_t ** @var{chain}, unsigned int * @var{chain_len}, gnutls_x509_crt_t ** @var{extra_certs}, unsigned int * @var{extra_certs_len}, gnutls_x509_crl_t * @var{crl}, unsigned int @var{flags})
Packit aea12f
@var{p12}: A pkcs12 type
Packit aea12f
Packit aea12f
@var{password}: optional password used to decrypt the structure, bags and keys.
Packit aea12f
Packit aea12f
@var{key}: a structure to store the parsed private key.
Packit aea12f
Packit aea12f
@var{chain}: the corresponding to key certificate chain (may be @code{NULL} )
Packit aea12f
Packit aea12f
@var{chain_len}: will be updated with the number of additional (may be @code{NULL} )
Packit aea12f
Packit aea12f
@var{extra_certs}: optional pointer to receive an array of additional
Packit aea12f
certificates found in the PKCS12 structure (may be @code{NULL} ).
Packit aea12f
Packit aea12f
@var{extra_certs_len}: will be updated with the number of additional
Packit aea12f
certs (may be @code{NULL} ).
Packit aea12f
Packit aea12f
@var{crl}: an optional structure to store the parsed CRL (may be @code{NULL} ).
Packit aea12f
Packit aea12f
@var{flags}: should be zero or one of GNUTLS_PKCS12_SP_*
Packit aea12f
Packit aea12f
This function parses a PKCS12 structure in  @code{pkcs12} and extracts the
Packit aea12f
private key, the corresponding certificate chain, any additional
Packit aea12f
certificates and a CRL. The structures in  @code{key} ,  @code{chain}  @code{crl} , and  @code{extra_certs} must not be initialized.
Packit aea12f
Packit aea12f
The  @code{extra_certs} and  @code{extra_certs_len} parameters are optional
Packit aea12f
and both may be set to @code{NULL} . If either is non-@code{NULL} , then both must
Packit aea12f
be set. The value for  @code{extra_certs} is allocated
Packit aea12f
using @code{gnutls_malloc()} .
Packit aea12f
Packit aea12f
Encrypted PKCS12 bags and PKCS8 private keys are supported, but
Packit aea12f
only with password based security and the same password for all
Packit aea12f
operations.
Packit aea12f
Packit aea12f
Note that a PKCS12 structure may contain many keys and/or certificates,
Packit aea12f
and there is no way to identify which key/certificate pair you want.
Packit aea12f
For this reason this function is useful for PKCS12 files that contain 
Packit aea12f
only one key/certificate pair and/or one CRL.
Packit aea12f
Packit aea12f
If the provided structure has encrypted fields but no password
Packit aea12f
is provided then this function returns @code{GNUTLS_E_DECRYPTION_FAILED} .
Packit aea12f
Packit aea12f
Note that normally the chain constructed does not include self signed
Packit aea12f
certificates, to comply with TLS' requirements. If, however, the flag 
Packit aea12f
@code{GNUTLS_PKCS12_SP_INCLUDE_SELF_SIGNED}  is specified then
Packit aea12f
self signed certificates will be included in the chain.
Packit aea12f
Packit aea12f
Prior to using this function the PKCS @code{12}  structure integrity must
Packit aea12f
be verified using @code{gnutls_pkcs12_verify_mac()} .
Packit aea12f
Packit aea12f
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit aea12f
negative error value.
Packit aea12f
Packit aea12f
@strong{Since:} 3.1.0
Packit aea12f
@end deftypefun