Fix dev cert setup for websocket test

This commit is contained in:
xinchen 2024-09-05 11:32:53 -07:00
Родитель 9df9984d24
Коммит aeb02e60c1
1 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

@ -85,12 +85,13 @@ namespace Test.Amqp
string testName = "WebSocketSslMutalAuthTest";
Address listenAddress = new Address("wss://localhost:18081/" + testName + "/");
X509Certificate2 cert = Test.Common.Extensions.GetCertificate("localhost");
string output;
int code = Exec("netsh.exe", string.Format("http show sslcert hostnameport={0}:{1}", listenAddress.Host, listenAddress.Port), out output);
if (code != 0)
{
X509Certificate2 cert = null;
Test.Common.Extensions.TryGetCertificate(StoreLocation.LocalMachine, StoreName.My, "localhost", out cert);
Assert.IsTrue(cert != null, "Failed to get dev-cert from LocalMachine store");
string args = string.Format("http add sslcert hostnameport={0}:{1} certhash={2} certstorename=MY appid={{{3}}} clientcertnegotiation=enable",
listenAddress.Host, listenAddress.Port, cert.Thumbprint, Guid.NewGuid());
code = Exec("netsh.exe", args, out output);