Skip to content
This repository has been archived by the owner on Jul 9, 2023. It is now read-only.

Question : How to install certificate for local machine #958

Open
Tushar-Mahajan41 opened this issue Apr 5, 2023 · 1 comment
Open

Question : How to install certificate for local machine #958

Tushar-Mahajan41 opened this issue Apr 5, 2023 · 1 comment

Comments

@Tushar-Mahajan41
Copy link

Tushar-Mahajan41 commented Apr 5, 2023

Problem: I have used proxy server in a window form app and it will be installed in machine and I am inspecting the traffic and take specific action(s).
Every user can run this application . When the application runs it asks to install titanium proxy certificate . I want certificate can be installed manually for once for one machine not for every user . How can i do this

This is how i am starting the proxy server

` proxyServer = new ProxyServer();

            proxyServer.CertificateManager.CertificateEngine = Titanium.Web.Proxy.Network.CertificateEngine.DefaultWindows;

            ExplicitProxyEndPoint explicitEndPoint = new(IPAddress.Any, 8000, true);

            proxyServer.AddEndPoint(explicitEndPoint);
            proxyServer.Start();
            proxyServer.BeforeResponse += OnResponse;
            proxyServer.SetAsSystemHttpProxy(explicitEndPoint);
            proxyServer.SetAsSystemHttpsProxy(explicitEndPoint);`

Thanks

@trontronicent
Copy link

Get the root cert .pfx file, install it via windows crypto snapp-in - install for machine in "trusted root authorities".
Now that it's trusted, ensure to load exactly that certificate either by path (or somehow directly via WinCertStore) on app start - and disable overwrite. If overwritten or missing (and thereby rebuilt by the engine) - the trust is useless, as it's a new cert.

I store my root cert for my apps on a central (readonly) shared folder.

_certificateManager.CertificateEngine = Titanium.Web.Proxy.Network.CertificateEngine.DefaultWindows;
_certificateManager.OverwritePfxFile = false;
bool rootCertLoaded = _certificateManager.LoadRootCertificate("pathToCert", "rootCertPass", false, X509KeyStorageFlags.DefaultKeySet);

if (rootCertLoaded && _certificateManager.IsRootCertificateMachineTrusted()) 
{
         foreach (var proxyServer in proxyServers)
         {
                 proxyServer.CertificateManager = _certificateManager;
         }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants