xref: /freebsd/crypto/openssl/doc/man3/SSL_get_peer_cert_chain.pod (revision f6a3b357e9be4c6423c85eff9a847163a0d307c8)
1=pod
2
3=head1 NAME
4
5SSL_get_peer_cert_chain, SSL_get0_verified_chain - get the X509 certificate
6chain of the peer
7
8=head1 SYNOPSIS
9
10 #include <openssl/ssl.h>
11
12 STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *ssl);
13 STACK_OF(X509) *SSL_get0_verified_chain(const SSL *ssl);
14
15=head1 DESCRIPTION
16
17SSL_get_peer_cert_chain() returns a pointer to STACK_OF(X509) certificates
18forming the certificate chain sent by the peer. If called on the client side,
19the stack also contains the peer's certificate; if called on the server
20side, the peer's certificate must be obtained separately using
21L<SSL_get_peer_certificate(3)>.
22If the peer did not present a certificate, NULL is returned.
23
24NB: SSL_get_peer_cert_chain() returns the peer chain as sent by the peer: it
25only consists of certificates the peer has sent (in the order the peer
26has sent them) it is B<not> a verified chain.
27
28SSL_get0_verified_chain() returns the B<verified> certificate chain
29of the peer including the peer's end entity certificate. It must be called
30after a session has been successfully established. If peer verification was
31not successful (as indicated by SSL_get_verify_result() not returning
32X509_V_OK) the chain may be incomplete or invalid.
33
34=head1 NOTES
35
36If the session is resumed peers do not send certificates so a NULL pointer
37is returned by these functions. Applications can call SSL_session_reused()
38to determine whether a session is resumed.
39
40The reference count of each certificate in the returned STACK_OF(X509) object
41is not incremented and the returned stack may be invalidated by renegotiation.
42If applications wish to use any certificates in the returned chain
43indefinitely they must increase the reference counts using X509_up_ref() or
44obtain a copy of the whole chain with X509_chain_up_ref().
45
46=head1 RETURN VALUES
47
48The following return values can occur:
49
50=over 4
51
52=item NULL
53
54No certificate was presented by the peer or no connection was established
55or the certificate chain is no longer available when a session is reused.
56
57=item Pointer to a STACK_OF(X509)
58
59The return value points to the certificate chain presented by the peer.
60
61=back
62
63=head1 SEE ALSO
64
65L<ssl(7)>, L<SSL_get_peer_certificate(3)>, L<X509_up_ref(3)>,
66L<X509_chain_up_ref(3)>
67
68=head1 COPYRIGHT
69
70Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
71
72Licensed under the OpenSSL license (the "License").  You may not use
73this file except in compliance with the License.  You can obtain a copy
74in the file LICENSE in the source distribution or at
75L<https://www.openssl.org/source/license.html>.
76
77=cut
78