From f0f66f4b1ecc885e23933111b6a8ef2219a79e08 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Wed, 28 Oct 2026 10:08:43 +0100 Subject: [PATCH] Fixed build against OpenSSL 4 X509_get_subject_name() now returns a const name. Build a new X509_NAME and set it as both subject and issuer instead. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lars Erik Wik --- libcfnet/tls_generic.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libcfnet/tls_generic.c b/libcfnet/tls_generic.c index d3882abb5ba..e34fb6dbc8a 100644 --- a/libcfnet/tls_generic.c +++ b/libcfnet/tls_generic.c @@ -480,10 +480,12 @@ X509 *TLSGenerateCertFromPrivKey(RSA *privkey) goto err3; } - X509_NAME *name = X509_get_subject_name(x509); + /* OpenSSL 4 returns a const name from X509_get_subject_name(), so build + * a new one and set it. */ + X509_NAME *name = X509_NAME_new(); if (name == NULL) { - Log(LOG_LEVEL_ERR, "X509_get_subject_name: %s", + Log(LOG_LEVEL_ERR, "X509_NAME_new: %s", TLSErrorString(ERR_get_error())); goto err3; } @@ -492,9 +494,11 @@ X509 *TLSGenerateCertFromPrivKey(RSA *privkey) ret += X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, (const unsigned char *) "a", -1, -1, 0); + ret += X509_set_subject_name(x509, name); ret += X509_set_issuer_name(x509, name); + X509_NAME_free(name); ret += X509_set_pubkey(x509, pkey); - if (ret < 3) + if (ret < 4) { Log(LOG_LEVEL_ERR, "Failed to set certificate details: %s", TLSErrorString(ERR_get_error()));