aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Sadie Powell2025-11-03 12:33:25 +0000
committerGravatar Sadie Powell2025-11-03 12:34:39 +0000
commit5d271bcb2188c052b2a57982661c309d10859c0d (patch)
tree8b73d96de7f07bfe139440ba0a4b4caaa830e1a0 /src
parentImprove the way client certificates are validated in ssl_openssl. (diff)
Modernize the certificate fetching code in ssl_openssl.
It is 2025 and we are using C++17 there is no need to declare variables like we are using C89.
Diffstat (limited to 'src')
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index 5a85f3586..e5f05b586 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -605,14 +605,10 @@ private:
void VerifyCertificate()
{
- X509* cert;
auto* certinfo = new ssl_cert();
this->certificate = certinfo;
- unsigned int n;
- unsigned char md[EVP_MAX_MD_SIZE];
-
- cert = SSL_get_peer_certificate(sess);
+ auto* cert = SSL_get_peer_certificate(sess);
if (!cert)
{
certinfo->error = "Could not get peer certificate: "+std::string(get_error());
@@ -653,15 +649,17 @@ private:
GetDNString(X509_get_subject_name(cert), certinfo->dn);
GetDNString(X509_get_issuer_name(cert), certinfo->issuer);
+ unsigned int mdlen;
+ unsigned char md[EVP_MAX_MD_SIZE];
for (const auto* digest : GetProfile().GetDigests())
{
- if (!X509_digest(cert, digest, md, &n))
+ if (!X509_digest(cert, digest, md, &mdlen))
{
certinfo->error = "Out of memory generating fingerprint";
}
else
{
- certinfo->fingerprints.push_back(Hex::Encode(md, n));
+ certinfo->fingerprints.push_back(Hex::Encode(md, mdlen));
}
}