blob: 69786d49c08b64955da2ee653104cad134e36b44 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
.\" $OpenBSD: PKCS12_parse.3,v 1.2 2016/11/06 15:52:50 jmc Exp $
.\"
.Dd $Mdocdate: November 6 2016 $
.Dt PKCS12_PARSE 3
.Os
.Sh NAME
.Nm PKCS12_parse
.Nd parse a PKCS#12 structure
.Sh SYNOPSIS
.In openssl/pkcs12.h
.Ft int
.Fo PKCS12_parse
.Fa "PKCS12 *p12"
.Fa "const char *pass"
.Fa "EVP_PKEY **pkey"
.Fa "X509 **cert"
.Fa "STACK_OF(X509) **ca"
.Fc
.Sh DESCRIPTION
.Fn PKCS12_parse
parses a PKCS12 structure.
.Pp
.Fa p12
is the
.Vt PKCS12
structure to parse.
.Fa pass
is the passphrase to use.
If successful, the private key will be written to
.Pf * Fa pkey ,
the corresponding certificate to
.Pf * Fa cert ,
and any additional certificates to
.Pf * Fa ca .
.Pp
The parameters
.Fa pkey
and
.Fa cert
cannot be
.Dv NULL .
.Fa ca
can be
.Dv NULL ,
in which case additional certificates will be discarded.
.Pf * Fa ca
can also be a valid STACK in which case additional certificates are
appended to
.Pf * Fa ca .
If
.Pf * Fa ca
is
.Dv NULL ,
a new STACK will be allocated.
.Pp
The
.Sy friendlyName
and
.Sy localKeyID
attributes (if present) of each certificate will be stored in the
.Fa alias
and
.Fa keyid
attributes of the
.Vt X509
structure.
.Sh RETURN VALUES
.Fn PKCS12_parse
returns 1 for success and 0 if an error occurred.
.Pp
The error can be obtained from
.Xr ERR_get_error 3 .
.Sh SEE ALSO
.Xr d2i_PKCS12 3
.Sh HISTORY
PKCS12_parse was added in OpenSSL 0.9.3.
.Sh BUGS
Only a single private key and corresponding certificate is returned by
this function.
More complex PKCS#12 files with multiple private keys will only return
the first match.
.Pp
Only
.Sy friendlyName
and
.Sy localKeyID
attributes are currently stored in certificates.
Other attributes are discarded.
.Pp
Attributes currently cannot be stored in the private key
.Vt EVP_PKEY
structure.
|