Skip to content
⌘ NSIS Forum Archive

Questions: About how to Import root certificate

5 posts

bankeris#

Questions: About how to Import root certificate

Hello,

I have bought Certificate for my Excel VSTO Project which is built with VisualStudio. Also seller gave me tool to sign .dll, .exe and other files with SHA256. To make my Add-In work on Excel I need to import root certificate. I found this thread:

https://nsis.sourceforge.io/Import_Root_Certificate

Question 1: I need to put whole Function to my .nsis project? or its enough only this code
Push C:\path\to\certificate.cer
Call AddCertificateToStore
Pop $0
${If} $0 != success
MessageBox MB_OK "import failed: $0"
${EndIf}
Question 2: My update installer uses "RequestExecutionLevel user". Can user import root certificate without having administrator rights?

Question 3: I Don't understand how to download latest NSIS version-> 3.06.1, it opens virstotal web, and nothing to click for a download. Or from now we need to create account there for a download? Or I'm just missing something obvious? 😁
Anders#
1) You need the whole function.

2) There are user and machine certs but that code installs it for the machine and you must request admin rights.

3) No idea, looks like a normal Sourceforge download to me, just go to nsis.sf.net. The thread here on the forum is something else.
bankeris#
Thanks for fast response. I also found that I don't need to install certificate into Machine, CurrentUser will do fine.

Can you help to change Function code to make it install for "CurrentUser" and Certificate must Install under "Trusted Publisher" ?

I found some C# example and tested on Console(.exe) and it worked. But it would be nice if NSIS could do this.

using System.Security.Cryptography.X509Certificates;
X509Store store = new X509Store(StoreName.TrustedPublisher, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadWrite);
X509Certificate2Collection collection = new X509Certificate2Collection();
X509Certificate2 cert = new X509Certificate2("MyCertLocation.cer");
store.Add(cert);
store.Close();