简体   繁体   中英

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

each time when I run unit tests by NUnit (2.6.4) that use titanium-web-proxy (3.0.398-beta) appears security warning about installing the certificate , but if I start titanium-web-proxy like the standalone app it asks only at first time and then starts without the security warning. The code of launching proxy at both projects the same:

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);
}

Previously I had this issue in our Production environment. I searched deeply and got this solution. This may be worth-able to solution to try

Kindly check the certificate file"rootCert.pfx" in the base folder.(This is the reason)

This certificate file has to be in the base location of where application running. Other wise Titanium Create a new certificate for each and every time.

If the certificate has same serial number then "You will not get any Security Message Warning"

the runtime will then look into the Trusted Root Certification Authority store and see if the certificate for the issuer of the publisher's certificate is installed in that store. It will then look at who the publisher on the certificate is, and see if their certificate is in the Trusted Publishers store. If those two things are true, then by default the user will not be prompted,

Note :

  • Titanium Proxy first check if the file exist otherwise it will generate a new one. If I was correct the file name was "rootCert.pfx".
  • Before you start the application go to the base folder and check the certificate file was there.
  • I don't have any idea how NUnit works

Thanks for the help, you are prompted me to solve this issue. Problem was that Titanium-web-proxy (3.0.503) generate new cert each time, So I am just set root cert by manual and it helps. Tests launching without the security warning.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM