Old 27th October 2020, 12:01   #1
bankeris
Junior Member
 
Join Date: Feb 2014
Posts: 27
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
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?
bankeris is offline   Reply With Quote
Old 27th October 2020, 12:10   #2
bankeris
Junior Member
 
Join Date: Feb 2014
Posts: 27
Since I can't edit my post. Forget Question 3.
bankeris is offline   Reply With Quote
Old 27th October 2020, 12:30   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,332
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.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 27th October 2020, 13:33   #4
bankeris
Junior Member
 
Join Date: Feb 2014
Posts: 27
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.

code:
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();

bankeris is offline   Reply With Quote
Old 27th October 2020, 13:40   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,332
You can look at the parameters for these functions on MSDN.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump