使用 titanium-web-proxy 开始单元测试后每次都请求证书

Requesting a certificate every time after the starts unit tests with titanium-web-proxy

每次我 运行 通过 NUnit(2.6.4) 使用 titanium-web-proxy 进行单元测试时(3.0.398-beta) 出现 security warning about installing the certificate,但如果我像独立应用程序一样启动 titanium-web-proxy,它只会在第一次询问,然后在没有安全警告的情况下启动。两个项目启动代理的代码相同:

private readonly ProxyServer _proxyServer = new ProxyServer();

public void ProxyStart()
{
    var explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, 8000);
    _proxyServer.AddEndPoint(explicitEndPoint);
    _proxyServer.Start();
    _proxyServer.SetAsSystemProxy(explicitEndPoint , ProxyProtocolType.AllHttp);
}

以前我在生产环境中遇到过这个问题。我深入搜索并得到了这个解决方案。这可能是值得尝试的解决方案

请检查基本文件夹中的证书文件"rootCert.pfx"。(这是原因)

此证书文件必须位于应用程序 运行 的基础位置。其他明智的 Titanium 每次都创建一个新证书。

如果证书有相同的序列号则"You will not get any Security Message Warning"

然后,运行时将查看受信任的根证书颁发机构存储,并查看发布者证书颁发者的证书是否安装在该存储中。然后它将查看证书上的发布者是谁,并查看他们的证书是否在 Trusted Publishers 商店中。如果这两件事都是真的,那么默认情况下不会提示用户,

注:

  • Titanium Proxy 首先检查文件是否存在,否则会 生成一个新的。如果我是正确的文件名是 "rootCert.pfx"。
  • 在启动应用程序之前,请转到基本文件夹并检查 证书文件在那里。
  • 我不知道 NUnit 是如何工作的

感谢您的帮助,提示我解决这个问题。 问题是 Titanium-web-proxy (3.0.503) 每次都会生成新的证书, 所以我只是通过手动设置根证书,它有帮助。 测试在没有安全警告的情况下启动。

  ProxyServer.CertificateManager.RootCertificate = new X509Certificate2(path + "\Resources\rootCert.pfx");