Debian Codegraph @

upstream/debian-unstable/man3/X509_get_pubkey.3ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "X509_GET_PUBKEY 3SSL"
58 .TH X509_GET_PUBKEY 3SSL 2026-04-07 3.6.2 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 X509_get_pubkey, X509_get0_pubkey, X509_set_pubkey, X509_get_X509_PUBKEY,
65 X509_REQ_get_pubkey, X509_REQ_get0_pubkey, X509_REQ_set_pubkey,
66 X509_REQ_get_X509_PUBKEY \- get or set certificate or certificate request
67 public key
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 .Vb 1
71 \& #include <openssl/x509.h>
72 \&
73 \& EVP_PKEY *X509_get_pubkey(X509 *x);
74 \& EVP_PKEY *X509_get0_pubkey(const X509 *x);
75 \& int X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
76 \& X509_PUBKEY *X509_get_X509_PUBKEY(const X509 *x);
77 \&
78 \& EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req);
79 \& EVP_PKEY *X509_REQ_get0_pubkey(X509_REQ *req);
80 \& int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
81 \& X509_PUBKEY *X509_REQ_get_X509_PUBKEY(X509_REQ *x);
82 .Ve
83 .SH DESCRIPTION
84 .IX Header "DESCRIPTION"
85 \&\fBX509_get_pubkey()\fR attempts to decode the public key for certificate \fBx\fR. If
86 successful it returns the public key as an \fBEVP_PKEY\fR pointer with its
87 reference count incremented: this means the returned key must be freed up
88 after use. \fBX509_get0_pubkey()\fR is similar except it does \fBnot\fR increment
89 the reference count of the returned \fBEVP_PKEY\fR so it must not be freed up
90 after use.
91 .PP
92 \&\fBX509_get_X509_PUBKEY()\fR returns an internal pointer to the \fBX509_PUBKEY\fR
93 structure which encodes the certificate of \fBx\fR. The returned value
94 must not be freed up after use.
95 .PP
96 \&\fBX509_set_pubkey()\fR attempts to set the public key for certificate \fBx\fR to
97 \&\fBpkey\fR. The key \fBpkey\fR should be freed up after use.
98 .PP
99 \&\fBX509_REQ_get_pubkey()\fR, \fBX509_REQ_get0_pubkey()\fR, \fBX509_REQ_set_pubkey()\fR and
100 \&\fBX509_REQ_get_X509_PUBKEY()\fR are similar but operate on certificate request \fBreq\fR.
101 .SH NOTES
102 .IX Header "NOTES"
103 The first time a public key is decoded the \fBEVP_PKEY\fR structure is
104 cached in the certificate or certificate request itself. Subsequent calls
105 return the cached structure with its reference count incremented to
106 improve performance.
107 .SH "RETURN VALUES"
108 .IX Header "RETURN VALUES"
109 \&\fBX509_get_pubkey()\fR, \fBX509_get0_pubkey()\fR, \fBX509_get_X509_PUBKEY()\fR,
110 \&\fBX509_REQ_get_pubkey()\fR and \fBX509_REQ_get_X509_PUBKEY()\fR return a public key or
111 \&\fBNULL\fR if an error occurred.
112 .PP
113 \&\fBX509_set_pubkey()\fR and \fBX509_REQ_set_pubkey()\fR return 1 for success and 0
114 for failure.
115 .SH "SEE ALSO"
116 .IX Header "SEE ALSO"
117 \&\fBd2i_X509\fR\|(3),
118 \&\fBERR_get_error\fR\|(3),
119 \&\fBX509_CRL_get0_by_serial\fR\|(3),
120 \&\fBX509_get0_signature\fR\|(3),
121 \&\fBX509_get_ext_d2i\fR\|(3),
122 \&\fBX509_get_extension_flags\fR\|(3),
123 \&\fBX509_get_subject_name\fR\|(3),
124 \&\fBX509_get_version\fR\|(3),
125 \&\fBX509_NAME_add_entry_by_txt\fR\|(3),
126 \&\fBX509_NAME_ENTRY_get_object\fR\|(3),
127 \&\fBX509_NAME_get_index_by_NID\fR\|(3),
128 \&\fBX509_NAME_print_ex\fR\|(3),
129 \&\fBX509_new\fR\|(3),
130 \&\fBX509_sign\fR\|(3),
131 \&\fBX509V3_get_d2i\fR\|(3),
132 \&\fBX509_verify_cert\fR\|(3)
133 .SH COPYRIGHT
134 .IX Header "COPYRIGHT"
135 Copyright 2015\-2016 The OpenSSL Project Authors. All Rights Reserved.
136 .PP
137 Licensed under the Apache License 2.0 (the "License"). You may not use
138 this file except in compliance with the License. You can obtain a copy
139 in the file LICENSE in the source distribution or at
140 <https://www.openssl.org/source/license.html>.