diff options
author | Todd Short <tshort@akamai.com> | 2019-04-11 16:47:13 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-07-16 09:08:21 +0200 |
commit | 8c2bfd25129aea1b1f1b66ec753b21955f8ed523 (patch) | |
tree | 530798b60ed46a10265c5a061dedfd2694918ce3 /ssl/ssl_lib.c | |
parent | Configure: fix minor typo in apitable comment (diff) | |
download | openssl-8c2bfd25129aea1b1f1b66ec753b21955f8ed523.tar.xz openssl-8c2bfd25129aea1b1f1b66ec753b21955f8ed523.zip |
Add SSL_get[01]_peer_certificate()
Deprecate SSL_get_peer_certificte() and replace with
SSL_get1_peer_certificate().
Add SSL_get0_peer_certificate.
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/8730)
Diffstat (limited to 'ssl/ssl_lib.c')
-rw-r--r-- | ssl/ssl_lib.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index c3174a7c91..243c0ed7c9 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -1524,23 +1524,24 @@ int SSL_has_pending(const SSL *s) return RECORD_LAYER_read_pending(&s->rlayer); } -X509 *SSL_get_peer_certificate(const SSL *s) +X509 *SSL_get1_peer_certificate(const SSL *s) { - X509 *r; + X509 *r = SSL_get0_peer_certificate(s); - if ((s == NULL) || (s->session == NULL)) - r = NULL; - else - r = s->session->peer; - - if (r == NULL) - return r; - - X509_up_ref(r); + if (r != NULL) + X509_up_ref(r); return r; } +X509 *SSL_get0_peer_certificate(const SSL *s) +{ + if ((s == NULL) || (s->session == NULL)) + return NULL; + else + return s->session->peer; +} + STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s) { STACK_OF(X509) *r; |