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

Commit 6b2d758

Browse files
committed
Locate makecert.exe next to the assembly
It was located from the current directory. This can result in a FileNotFoundException when an application that uses Titanium-Web-Proxy is launched from another path, the root certificate is not registered and capturing is started . E.g. c:\> test\test.exe
1 parent 9a5a348 commit 6b2d758

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Titanium.Web.Proxy/Helpers/CertificateManager.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics;
44
using System.Collections.Generic;
55
using System.Security.Cryptography.X509Certificates;
6+
using System.Reflection;
67

78
namespace Titanium.Web.Proxy.Helpers
89
{
@@ -112,14 +113,16 @@ protected virtual void CreateCertificate(string[] args)
112113
{
113114
using (var process = new Process())
114115
{
115-
if (!File.Exists("makecert.exe"))
116+
string file = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "makecert.exe");
117+
118+
if (!File.Exists(file))
116119
throw new Exception("Unable to locate 'makecert.exe'.");
117120

118121
process.StartInfo.Verb = "runas";
119122
process.StartInfo.Arguments = args != null ? args[0] : string.Empty;
120123
process.StartInfo.CreateNoWindow = true;
121124
process.StartInfo.UseShellExecute = false;
122-
process.StartInfo.FileName = "makecert.exe";
125+
process.StartInfo.FileName = file;
123126

124127
process.Start();
125128
process.WaitForExit();

0 commit comments

Comments
 (0)