From 1e3b1511081c9d5575b91269afdce68a215cd18c Mon Sep 17 00:00:00 2001 From: Gianfranco Costamagna Date: Wed, 29 Jul 2026 16:39:00 +0200 Subject: [PATCH] x509-create-sign.cpp: Fix build failure with Openssl 4.0 --- src/VBox/Runtime/common/crypto/ssl-openssl.cpp | 2 +- src/VBox/Runtime/common/crypto/x509-create-sign.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/VBox/Runtime/common/crypto/ssl-openssl.cpp b/src/VBox/Runtime/common/crypto/ssl-openssl.cpp index 67f41ebfa03d..286730c12cb8 100644 --- a/src/VBox/Runtime/common/crypto/ssl-openssl.cpp +++ b/src/VBox/Runtime/common/crypto/ssl-openssl.cpp @@ -422,7 +422,7 @@ RTDECL(int) RTCrSslSessionGetCertIssuerNameAsString(RTCRSSLSESSION hSslSession, X509 *pCert = SSL_get_certificate(pThis->pSsl); if (pCert) { - X509_NAME *pIssuer = X509_get_issuer_name(pCert); + const X509_NAME *pIssuer = X509_get_issuer_name(pCert); if (pIssuer) { char *pszSrc = X509_NAME_oneline(pIssuer, NULL, 0); diff --git a/src/VBox/Runtime/common/crypto/x509-create-sign.cpp b/src/VBox/Runtime/common/crypto/x509-create-sign.cpp index dad632a7ac1a..a52002ea15ab 100644 --- a/src/VBox/Runtime/common/crypto/x509-create-sign.cpp +++ b/src/VBox/Runtime/common/crypto/x509-create-sign.cpp @@ -156,7 +156,8 @@ RTDECL(int) RTCrX509Certificate_GenerateSelfSignedRsa(RTDIGESTTYPE enmDigestType /** @todo check what the subject name is... Offer way to specify it? */ /* Make it self signed: */ - X509_NAME *pX509Name = X509_get_subject_name(pNewCert); + X509_NAME *pX509Name = X509_NAME_new(); + X509_set_subject_name(pNewCert, pX509Name); rcOssl = X509_NAME_add_entry_by_txt(pX509Name, "CN", MBSTRING_ASC, (unsigned char *) pvSubject, -1, -1, 0); AssertStmt(rcOssl > 0, rc = RTErrInfoSet(pErrInfo, VERR_GENERAL_FAILURE, "X509_NAME_add_entry_by_txt failed")); rcOssl = X509_set_issuer_name(pNewCert, pX509Name); @@ -211,6 +212,7 @@ RTDECL(int) RTCrX509Certificate_GenerateSelfSignedRsa(RTDIGESTTYPE enmDigestType rc = RTErrInfoSet(pErrInfo, VERR_CR_KEY_GEN_FAILED_RSA, "X509_sign failed"); } + X509_NAME_free(pX509Name); X509_free(pNewCert); } else