Skip to content

Commit 5142eea

Browse files
committed
SSL_get_peer_certificate() is deprecated since OpenSSL 3.0
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 <jaeckel-floss@eyet-services.de>
1 parent 5dd9e4b commit 5142eea

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/tls_openssl.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@
5151

5252
#if OPENSSL_VERSION_NUMBER < 0x30000000L
5353
#define STROPHE_ERR_func_error_string(e) ERR_func_error_string(e)
54+
#define STROPHE_SSL_get1_peer_certificate(s) SSL_get_peer_certificate(s)
5455
#else
5556
#define STROPHE_ERR_func_error_string(e) ""
57+
#define STROPHE_SSL_get1_peer_certificate(s) SSL_get1_peer_certificate(s)
5658
#endif
5759

5860
#if OPENSSL_VERSION_NUMBER < 0x10100000L
@@ -762,7 +764,7 @@ void tls_free(tls_t *tls)
762764
xmpp_tlscert_t *tls_peer_cert(xmpp_conn_t *conn)
763765
{
764766
if (conn && conn->tls && conn->tls->ssl) {
765-
X509 *cert = SSL_get_peer_certificate(conn->tls->ssl);
767+
X509 *cert = STROPHE_SSL_get1_peer_certificate(conn->tls->ssl);
766768
if (cert) {
767769
xmpp_tlscert_t *tlscert = _x509_to_tlscert(conn->ctx, cert);
768770
X509_free(cert);
@@ -1034,7 +1036,7 @@ static void _tls_dump_cert_info(tls_t *tls)
10341036
X509 *cert;
10351037
char *name;
10361038

1037-
cert = SSL_get_peer_certificate(tls->ssl);
1039+
cert = STROPHE_SSL_get1_peer_certificate(tls->ssl);
10381040
if (cert == NULL)
10391041
strophe_debug(tls->ctx, "tls", "Certificate was not presented by peer");
10401042
else {

0 commit comments

Comments
 (0)