1*2175Sjp161948=pod
2*2175Sjp161948
3*2175Sjp161948=head1 NAME
4*2175Sjp161948
5*2175Sjp161948SSL_get_peer_certificate - get the X509 certificate of the peer
6*2175Sjp161948
7*2175Sjp161948=head1 SYNOPSIS
8*2175Sjp161948
9*2175Sjp161948 #include <openssl/ssl.h>
10*2175Sjp161948
11*2175Sjp161948 X509 *SSL_get_peer_certificate(const SSL *ssl);
12*2175Sjp161948
13*2175Sjp161948=head1 DESCRIPTION
14*2175Sjp161948
15*2175Sjp161948SSL_get_peer_certificate() returns a pointer to the X509 certificate the
16*2175Sjp161948peer presented. If the peer did not present a certificate, NULL is returned.
17*2175Sjp161948
18*2175Sjp161948=head1 NOTES
19*2175Sjp161948
20*2175Sjp161948Due to the protocol definition, a TLS/SSL server will always send a
21*2175Sjp161948certificate, if present. A client will only send a certificate when
22*2175Sjp161948explicitly requested to do so by the server (see
23*2175Sjp161948L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>). If an anonymous cipher
24*2175Sjp161948is used, no certificates are sent.
25*2175Sjp161948
26*2175Sjp161948That a certificate is returned does not indicate information about the
27*2175Sjp161948verification state, use L<SSL_get_verify_result(3)|SSL_get_verify_result(3)>
28*2175Sjp161948to check the verification state.
29*2175Sjp161948
30*2175Sjp161948The reference count of the X509 object is incremented by one, so that it
31*2175Sjp161948will not be destroyed when the session containing the peer certificate is
32*2175Sjp161948freed. The X509 object must be explicitly freed using X509_free().
33*2175Sjp161948
34*2175Sjp161948=head1 RETURN VALUES
35*2175Sjp161948
36*2175Sjp161948The following return values can occur:
37*2175Sjp161948
38*2175Sjp161948=over 4
39*2175Sjp161948
40*2175Sjp161948=item NULL
41*2175Sjp161948
42*2175Sjp161948No certificate was presented by the peer or no connection was established.
43*2175Sjp161948
44*2175Sjp161948=item Pointer to an X509 certificate
45*2175Sjp161948
46*2175Sjp161948The return value points to the certificate presented by the peer.
47*2175Sjp161948
48*2175Sjp161948=back
49*2175Sjp161948
50*2175Sjp161948=head1 SEE ALSO
51*2175Sjp161948
52*2175Sjp161948L<ssl(3)|ssl(3)>, L<SSL_get_verify_result(3)|SSL_get_verify_result(3)>,
53*2175Sjp161948L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>
54*2175Sjp161948
55*2175Sjp161948=cut
56