49 lines
2 KiB
Diff
49 lines
2 KiB
Diff
From c6b7fece1ec318c67ed8afa80ef914a135180a4f Mon Sep 17 00:00:00 2001
|
|
From: Ravi Kant Sharma <ravi.kant.sharma@canonical.com>
|
|
Date: Tue, 16 Jun 2026 10:08:17 +0200
|
|
Subject: [PATCH] Fix build error with OpenSSL 4
|
|
|
|
---
|
|
src/SSLVerifyHost.cpp | 4 ++--
|
|
src/Utils.cpp | 5 ++++-
|
|
2 files changed, 6 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/SSLVerifyHost.cpp b/src/SSLVerifyHost.cpp
|
|
index ccc20898e2..99b215bc23 100644
|
|
--- a/src/SSLVerifyHost.cpp
|
|
+++ b/src/SSLVerifyHost.cpp
|
|
@@ -306,8 +306,8 @@ typedef enum {
|
|
static HostnameValidationResult matches_common_name(const char* hostname,
|
|
const X509* server_cert) {
|
|
int common_name_loc = -1;
|
|
- X509_NAME_ENTRY* common_name_entry = nullptr;
|
|
- ASN1_STRING* common_name_asn1 = nullptr;
|
|
+ const X509_NAME_ENTRY* common_name_entry = nullptr;
|
|
+ const ASN1_STRING* common_name_asn1 = nullptr;
|
|
CONST_ASN1_STRING_DATA char* common_name_str = nullptr;
|
|
|
|
// Find the position of the CN field in the Subject field of the certificate
|
|
diff --git a/src/Utils.cpp b/src/Utils.cpp
|
|
index ed2c9c8386..744f61d195 100644
|
|
--- a/src/Utils.cpp
|
|
+++ b/src/Utils.cpp
|
|
@@ -129,7 +129,8 @@ void CUtils::GenerateCert(FILE* pOut) {
|
|
sEmailAddr += "@";
|
|
sEmailAddr += sHostName;
|
|
|
|
- X509_NAME* pName = X509_get_subject_name(pCert.get());
|
|
+ X509_NAME* pName = X509_NAME_new();
|
|
+ if (!pName) return;
|
|
X509_NAME_add_entry_by_txt(pName, "OU", MBSTRING_ASC,
|
|
(unsigned char*)pLogName, -1, -1, 0);
|
|
X509_NAME_add_entry_by_txt(pName, "CN", MBSTRING_ASC,
|
|
@@ -137,7 +138,9 @@ void CUtils::GenerateCert(FILE* pOut) {
|
|
X509_NAME_add_entry_by_txt(pName, "emailAddress", MBSTRING_ASC,
|
|
(unsigned char*)sEmailAddr.c_str(), -1, -1, 0);
|
|
|
|
+ X509_set_subject_name(pCert.get(), pName);
|
|
X509_set_issuer_name(pCert.get(), pName);
|
|
+ X509_NAME_free(pName);
|
|
|
|
if (!X509_sign(pCert.get(), pKey.get(), EVP_sha256())) return;
|
|
|