mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-07-02 10:38:16 +00:00
fix: validate certificate for private key presence in DebugWebsocketSink
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
parent
a9dd57fdaf
commit
b318e7f365
1 changed files with 7 additions and 1 deletions
|
|
@ -262,7 +262,13 @@ namespace PepperDash.Core
|
||||||
using (var ms = new MemoryStream())
|
using (var ms = new MemoryStream())
|
||||||
{
|
{
|
||||||
store.Save(ms, passwordChars, new SecureRandom());
|
store.Save(ms, passwordChars, new SecureRandom());
|
||||||
return new X509Certificate2(ms.ToArray(), certPassword);
|
var cert = new X509Certificate2(ms.ToArray(), certPassword);
|
||||||
|
|
||||||
|
if (!cert.HasPrivateKey)
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
string.Format("Certificate loaded from '{0}' does not contain a private key and cannot be used as a server certificate.", certPath));
|
||||||
|
|
||||||
|
return cert;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue