Skip to content

Commit

Permalink
SSL_get_peer_certificate() is deprecated since OpenSSL 3.0
Browse files Browse the repository at this point in the history
Unfortunately OpenSSL didn't implement a warning for deprecated macros, so
this wasn't discovered until now.

Discovered in [0].

OpenSSL patch to improve the situation proposed in [1].

[0] #244
[1] openssl/openssl#24296

Signed-off-by: Steffen Jaeckel <[email protected]>
  • Loading branch information
sjaeckel committed May 28, 2024
1 parent 5dd9e4b commit 5142eea
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/tls_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@

#if OPENSSL_VERSION_NUMBER < 0x30000000L
#define STROPHE_ERR_func_error_string(e) ERR_func_error_string(e)
#define STROPHE_SSL_get1_peer_certificate(s) SSL_get_peer_certificate(s)
#else
#define STROPHE_ERR_func_error_string(e) ""
#define STROPHE_SSL_get1_peer_certificate(s) SSL_get1_peer_certificate(s)
#endif

#if OPENSSL_VERSION_NUMBER < 0x10100000L
Expand Down Expand Up @@ -762,7 +764,7 @@ void tls_free(tls_t *tls)
xmpp_tlscert_t *tls_peer_cert(xmpp_conn_t *conn)
{
if (conn && conn->tls && conn->tls->ssl) {
X509 *cert = SSL_get_peer_certificate(conn->tls->ssl);
X509 *cert = STROPHE_SSL_get1_peer_certificate(conn->tls->ssl);
if (cert) {
xmpp_tlscert_t *tlscert = _x509_to_tlscert(conn->ctx, cert);
X509_free(cert);
Expand Down Expand Up @@ -1034,7 +1036,7 @@ static void _tls_dump_cert_info(tls_t *tls)
X509 *cert;
char *name;

cert = SSL_get_peer_certificate(tls->ssl);
cert = STROPHE_SSL_get1_peer_certificate(tls->ssl);
if (cert == NULL)
strophe_debug(tls->ctx, "tls", "Certificate was not presented by peer");
else {
Expand Down

0 comments on commit 5142eea

Please sign in to comment.