Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
when the application is published, the users require pfx certification authorization to use the console application on their machine.


Where do I need to locate the .pfx file in the project when the user runs the .exe file and the application builds.

What I have tried:

C#
//project solution is not Web


SLN
 <Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>.netcoreapp3.1</TargetFramework>
    <!--Other Properties-->
  </PropertyGroup>

</Project>


C#
//program.cs does not have startup.cs file
//how could I set up pfx certificate for this console app to enable user’s machine to use this published console application

 public static async Task<int> Main(string[] args)
{
Console.WriteLine("Hello, your are enable to use this console app, you passed .pfx certification");
}
Posted
Updated 19-Sep-21 12:44pm
v2

1 solution

A simple form of signing is with SignTool.exe and an Authenticode certificate (which you can buy), it could look like this:
signtool sign /f MyCert.pfx /p MyPassword /fd SHA256 MyFile.exe

See: SignTool.exe (Sign Tool) | Microsoft Docs[^]
and: Everything you need to know about Authenticode Code Signing | Microsoft Docs[^]

You don't need to do anything in code for this.
It can however be difficult to find the location of SignTool.exe, as it seems to change with every new Windows version.
Most of the time it can be found in:
C:\Program Files (x86)\Windows Kits\10\App Certification Kit\signtool.exe

Another option if you don't want to buy a certificate is: Creating Self-signed Certificates[^]
 
Share this answer
 
v3
Comments
JimB_ 19-Sep-21 18:45pm    
Hi Rick
I updated the question could you please read it again? thanks for your help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900