Can I use Inno Setup to import a .cer
file (a certificate)?
How can I do it?
I need to create a certificate installer for Windows XP, Windows Vista and Windows 7.
Can I use Inno Setup to import a .cer
file (a certificate)?
How can I do it?
I need to create a certificate installer for Windows XP, Windows Vista and Windows 7.
Actually the CertMgr.exe
is not available on all PCs and furthermore it does not appear to be redistributable (as hinted by @TLama); and besides you don't even need it.
CertUtil
is available on every Windows machine (that I have tested) and works perfectly:
[Run]
Filename: "certutil.exe"; Parameters: "-addstore ""TrustedPublisher"" {app}\MyCert.cer"; \
StatusMsg: "Adding trusted publisher..."
Add Certmgr.exe and yourcertificate.cer into setup:
[Files]
Source: CertMgr.exe; DestDir: {app}; Flags: deleteafterinstall
Source: yourcertificate.cer; DestDir: {app}; Flags: deleteafterinstall
And in [Run] section, write something like this:
Filename: {app}\CertMgr.exe; Parameters: "-add -all -c yourcertificate.cer -s -r localmachine trustedpublisher"; Flags: waituntilterminated runhidden;
The reply by SlowLearner and Martin Prikryl is correct. However, a comment states the command requires elevated privileges. If you use the -user
command it will access the user store therefore not requiring elevation:
[Run]
Filename: "certutil.exe"; Parameters: "-user -addstore ""Root"" {app}\MyCert.cer"; \
StatusMsg: "Adding root certificate..."