Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
9EOR9 committed Jun 16, 2021
2 parents 74a405d + b9a4719 commit 66732cc
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions libmariadb/secure/schannel_certs.c
Expand Up @@ -710,7 +710,9 @@ static SECURITY_STATUS load_private_key(CERT_CONTEXT* cert, char* private_key_st
cert_key_context.cbSize = sizeof(cert_key_context);

/* assign private key to certificate context */
if (!CertSetCertificateContextProperty(cert, CERT_KEY_CONTEXT_PROP_ID, 0, &cert_key_context))
if (!CertSetCertificateContextProperty(cert, CERT_KEY_CONTEXT_PROP_ID,
CERT_STORE_NO_CRYPT_RELEASE_FLAG,
&cert_key_context))
{
FAIL("CertSetCertificateContextProperty failed");
}
Expand Down Expand Up @@ -838,18 +840,15 @@ void schannel_free_cert_context(const CERT_CONTEXT* cert)
CERT_KEY_CONTEXT cert_key_context = { 0 };
cert_key_context.cbSize = sizeof(cert_key_context);
DWORD cbData = sizeof(CERT_KEY_CONTEXT);
HCRYPTPROV hProv = 0;

if (CertGetCertificateContextProperty(cert, CERT_KEY_CONTEXT_PROP_ID, &cert_key_context, &cbData))
{
CryptReleaseContext(cert_key_context.hCryptProv, 0);
hProv = cert_key_context.hCryptProv;
}
else
CertFreeCertificateContext(cert);
if (hProv)
{
/*
At this point, there are serious doubts the context was created by
channel_create_cert_context().
*/
assert(0);
CryptReleaseContext(cert_key_context.hCryptProv, 0);
}
CertFreeCertificateContext(cert);
}

0 comments on commit 66732cc

Please sign in to comment.