1SSL_GET_PEER_CERTIFICATE(3ossl) OpenSSL SSL_GET_PEER_CERTIFICATE(3ossl)
2
3
4
6 SSL_get_peer_certificate, SSL_get0_peer_certificate,
7 SSL_get1_peer_certificate - get the X509 certificate of the peer
8
10 #include <openssl/ssl.h>
11
12 X509 *SSL_get_peer_certificate(const SSL *ssl);
13 X509 *SSL_get0_peer_certificate(const SSL *ssl);
14 X509 *SSL_get1_peer_certificate(const SSL *ssl);
15
17 These functions return a pointer to the X509 certificate the peer
18 presented. If the peer did not present a certificate, NULL is returned.
19
21 Due to the protocol definition, a TLS/SSL server will always send a
22 certificate, if present. A client will only send a certificate when
23 explicitly requested to do so by the server (see
24 SSL_CTX_set_verify(3)). If an anonymous cipher is used, no certificates
25 are sent.
26
27 That a certificate is returned does not indicate information about the
28 verification state, use SSL_get_verify_result(3) to check the
29 verification state.
30
31 The reference count of the X509 object returned by
32 SSL_get1_peer_certificate() is incremented by one, so that it will not
33 be destroyed when the session containing the peer certificate is freed.
34 The X509 object must be explicitly freed using X509_free().
35
36 The reference count of the X509 object returned by
37 SSL_get0_peer_certificate() is not incremented, and must not be freed.
38
39 SSL_get_peer_certificate() is an alias of SSL_get1_peer_certificate().
40
42 The following return values can occur:
43
44 NULL
45 No certificate was presented by the peer or no connection was
46 established.
47
48 Pointer to an X509 certificate
49 The return value points to the certificate presented by the peer.
50
52 ssl(7), SSL_get_verify_result(3), SSL_CTX_set_verify(3)
53
55 SSL_get0_peer_certificate() and SSL_get1_peer_certificate() were added
56 in 3.0.0. SSL_get_peer_certificate() was deprecated in 3.0.0.
57
59 Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
60
61 Licensed under the Apache License 2.0 (the "License"). You may not use
62 this file except in compliance with the License. You can obtain a copy
63 in the file LICENSE in the source distribution or at
64 <https://www.openssl.org/source/license.html>.
65
66
67
683.0.5 2022-07-05 SSL_GET_PEER_CERTIFICATE(3ossl)