
#use wml::openssl-macros area=docs page=SSL_get_peer_certificate

<title>Documents, SSL_get_peer_certificate(3)</title>

<h1>SSL_get_peer_certificate(3)</h1>

#use wml::imp::generic

{:
## What's this? [[s|(<STRONG>[^<].+?)</A>(</STRONG><DD>)|$1$2|sg]]
[[s|<P>\s+<P>|<P>|sg]]
[[s|<P>\s+</|</|sg]]
[[s|<DD>\s*<DT>|<DD>&nbsp;<DT>|sg]]
[[s|<DD>\s*</DL>|<DD>&nbsp;</DL>|sg]]
[[s|\[|&#91;|sg]]
[[s|\]|&#93;|sg]]

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
	<LI><A HREF="#NOTES">NOTES</A>
	<LI><A HREF="#RETURN_VALUES">RETURN VALUES</A>
	<LI><A HREF="#SEE_ALSO">SEE ALSO</A>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="NAME">NAME</A></H1>
<P>
SSL_get_peer_certificate - get the X509 certificate of the peer

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/ssl.h&gt;
</PRE>
<PRE> X509 *SSL_get_peer_certificate(const SSL *ssl);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
<CODE>SSL_get_peer_certificate()</CODE> returns a pointer to the X509
certificate the peer presented. If the peer did not present a certificate,
NULL is returned.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
Due to the protocol definition, a TLS/SSL server will always send a
certificate, if present. A client will only send a certificate when
explicitly requested to do so by the server (see
<A HREF="../ssl/SSL_CTX_set_verify.html#">SSL_CTX_set_verify(3)</A>). If an anonymous cipher is used, no certificates are sent.

</P>
<P>
That a certificate is returned does not indicate information about the
verification state, use <A HREF="../ssl/SSL_get_verify_result.html#">SSL_get_verify_result(3)</A>
to check the verification state.

</P>
<P>
The reference count of the X509 object is incremented by one, so that it
will not be destroyed when the session containing the peer certificate is
freed. The X509 object must be explicitly freed using
<CODE>X509_free().</CODE>

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
The following return values can occur:

</P>
<DL>
<DT><STRONG><A NAME="item_NULL">NULL</A></STRONG><DD>
<P>
No certificate was presented by the peer or no connection was established.

</P>
<DT><STRONG><A NAME="item_Pointer">Pointer to an X509 certificate</A></STRONG><DD>
<P>
The return value points to the certificate presented by the peer.

</P>
</DL>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
<A HREF="../ssl/ssl.html#">ssl(3)</A>, <A HREF="../ssl/SSL_get_verify_result.html#">SSL_get_verify_result(3)</A>,
<A HREF="../ssl/SSL_CTX_set_verify.html#">SSL_CTX_set_verify(3)</A>



</P>
:}


