SSL_get_peer_certificate.pod 2.2 KB

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