Tag Archives: ImageRemoveCertificate
FileUnsigner – Remove digital certificates from files
This small tool was created to simplify the process that was discussed at Remove digital signature from a file using C# and simply aid the people that didn’t have the knowledge on how to compile the code posted there.
This is a small standalone tool that will simply remove the digital signature of any file.
The usage is fairly simple. Either drag and drop the files you want to unsign on the application or use command prompt with the following parameters:
FileUnsigner.exe <options> <file1> <file2> …
Current Options:
/f Forces the program to remove a digital signiture even if one is not detected.
Posted in Software Releases.
Tagged C#, csharp, digital signiture, fluxbytes, ImageRemoveCertificate
Remove digital signature from a file using C#
There are two reasons why you might want to consider removing the digital signature from some of the files you are using, especially third party libraries.
The first reason is because in many cases it will greatly speed up your programs start-up time. The reason for that is because if a file is signed with Microsoft digital certificate as an example on runtime it will attempt to verify the signature which in most cases it requires an internet connection. In cases where the user might not have an active internet connection or if the verification attempt is blocked by a firewall or any other reason, it will greatly increase the time your application will take to start.
Another important reason for removing a digital signature from a library you want to distribute alongside with your software is that a lot of users feel alarmed when an application tries to establish a connection at start-up, especially if the type of the application you are making doesn’t sound like the type it requires to connect somewhere.
Thankfully it is fairly easy to remove a signature from a file using the ImageRemoveCertificate
API function. Below you can find a snippet that illustrates how it can be implemented.
1 2 | [System.Runtime.InteropServices.DllImport("Imagehlp.dll ")] private static extern bool ImageRemoveCertificate(IntPtr handle, int index); |
1 2 3 4 5 6 7 8 | private void UnsignFile(string file) { using (System.IO.FileStream fs = new System.IO.FileStream(file, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite)) { ImageRemoveCertificate(fs.SafeFileHandle.DangerousGetHandle(), 0); fs.Close(); } } |
If you would like to use the above code but have no knowladge on how to compile it then simply download the already compiled version from FileUnsigner v1.0.
Posted in C#.
Tagged C#, csharp, digital signiture, ImageRemoveCertificate, snippet, source, winforms