How to add code signing certificates using DOS cmd prompt and Powershell

  • KM03554404
  • 11-Nov-2019
  • 11-Nov-2019

Summary

How to add code signing certificates using DOS cmd prompt and Powershell

Question

How to add code signing certificates using DOS cmd prompt and Powershell

Answer

It is possilbe to add certificates certificates to the “Trusted Root Certification Authorities” and “Trusted Publishers” stores using DOS cmd prompt or Powershell

Mind that the path and certificate file name in the below examples are “D:\Temp\Sectigo.cer”. Of course specify your own...

 

Dos cmd prompt – run as admin…

 

certutil.exe -addstore -enterprise -f -v root "D:\Temp\Sectigo.cer"

certutil.exe -addstore -enterprise -f "TRUSTEDPUBLISHER" "D:\Temp\Sectigo.cer" 

 

Powershell – run as admin - Add to local machine “Trusted Root Certification Authorities” ...

 

$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("D:\Temp\Sectigo.cer")

$rootStore = Get-Item cert:\LocalMachine\Root

$rootStore.Open("ReadWrite")

$rootStore.Add($cert)

$rootStore.Close()

 

Powershell – run as admin - Add to local machine “Trusted Publishers”...

 

$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("D:\Temp\Sectigo.cer")

$rootStore = Get-Item cert:\LocalMachine\TRUSTEDPUBLISHER

$rootStore.Open("ReadWrite")

$rootStore.Add($cert)

$rootStore.Close()