xref: /freebsd/crypto/openssl/doc/man3/SSL_get_peer_certificate.pod (revision a03411e84728e9b267056fd31c7d1d9d1dc1b01e)
1=pod
2
3=head1 NAME
4
5SSL_get_peer_certificate,
6SSL_get0_peer_certificate,
7SSL_get1_peer_certificate - get the X509 certificate of the peer
8
9=head1 SYNOPSIS
10
11 #include <openssl/ssl.h>
12
13 X509 *SSL_get_peer_certificate(const SSL *ssl);
14 X509 *SSL_get0_peer_certificate(const SSL *ssl);
15 X509 *SSL_get1_peer_certificate(const SSL *ssl);
16
17=head1 DESCRIPTION
18
19These functions return a pointer to the X509 certificate the
20peer presented. If the peer did not present a certificate, NULL is returned.
21
22=head1 NOTES
23
24Due to the protocol definition, a TLS/SSL server will always send a
25certificate, if present. A client will only send a certificate when
26explicitly requested to do so by the server (see
27L<SSL_CTX_set_verify(3)>). If an anonymous cipher
28is used, no certificates are sent.
29
30That a certificate is returned does not indicate information about the
31verification state, use L<SSL_get_verify_result(3)>
32to check the verification state.
33
34The reference count of the X509 object returned by SSL_get1_peer_certificate()
35is incremented by one, so that it will not be destroyed when the session
36containing the peer certificate is freed. The X509 object must be explicitly
37freed using X509_free().
38
39The reference count of the X509 object returned by SSL_get0_peer_certificate()
40is not incremented, and must not be freed.
41
42SSL_get_peer_certificate() is an alias of SSL_get1_peer_certificate().
43
44=head1 RETURN VALUES
45
46The following return values can occur:
47
48=over 4
49
50=item NULL
51
52No certificate was presented by the peer or no connection was established.
53
54=item Pointer to an X509 certificate
55
56The return value points to the certificate presented by the peer.
57
58=back
59
60=head1 SEE ALSO
61
62L<ssl(7)>, L<SSL_get_verify_result(3)>,
63L<SSL_CTX_set_verify(3)>
64
65=head1 HISTORY
66
67SSL_get0_peer_certificate() and SSL_get1_peer_certificate() were added in 3.0.0.
68SSL_get_peer_certificate() was deprecated in 3.0.0.
69
70=head1 COPYRIGHT
71
72Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
73
74Licensed under the Apache License 2.0 (the "License").  You may not use
75this file except in compliance with the License.  You can obtain a copy
76in the file LICENSE in the source distribution or at
77L<https://www.openssl.org/source/license.html>.
78
79=cut
80