Abhinay
Posts: 36
Joined: Wed Feb 27, 2019 9:33 am

How to add a step to the 'App' installer which installs the attached certificate (*.device.weir)

How to add a step to the 'App' installer which installs the attached certificate (*.device.weir) into the Local Machine / Personal certificate store.
This certificate is used to validate the 'Access Token'.
The installer should also be checking that a (*.device.syn.weir) certificate is installed in the Local Machine / Personal certificate store, but not actually installing this certificate. How do we achieve this using powershell or vb script to perform this check.
Abhinay
Posts: 36
Joined: Wed Feb 27, 2019 9:33 am

Re: How to add a step to the 'App' installer which installs the attached certificate (*.device.weir)

I added the -->"Install Certificate' in the -->Custom Actions, How do i give the path of the APPDIR or the certificate stored in the "Files and Folders" section.
secondly where in the -->dialogs section i need to add this powershell script.
I was able to find the certificate using power shell
SET-LOCATION CERT:\LOCALMACHINE
GET-CHILDITEM
set-location my
GET-CHILDITEM
How do i validate that it has installed successfully
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: How to add a step to the 'App' installer which installs the attached certificate (*.device.weir)

Hello Abhinay,

Here are few things that are worth mentioning:

1- in order to import a certificate using PowerShell, you will need to run the PowerShell console elevated. With that being said, it means that your package must also be run elevated ("Install Parameters" page --> "Run as administrator").

2- the path to LocalMachine\Personal store is the following:

Code: Select all

cert:\LocalMachine\My
3- since you have added your certification file in "Files and Folders" page, you should schedule your custom action after the "Add resources" action group (because during the "Add resources" action group, the files are copied on the target machine). Beside that, your custom action's execution time must be "When the system is being modified (deferred)".

Here is a little sample script which installs a .pfx certificate in the LocalMachine\Personal store:

Code: Select all

$certLocation = "$appdir" + "\CaphyonTestCertificate.pfx"
Import-PfxCertificate -Filepath $certLocation -CertStoreLocation cert:\LocalMachine\My
where $appDir is a variable which stores the value of the [APPDIR] property.

I will attach a screenshot for your reference where I will highlight all the settings that need to be done:
CertPS.PNG
CertPS.PNG (67.94 KiB) Viewed 4047 times
Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Abhinay
Posts: 36
Joined: Wed Feb 27, 2019 9:33 am

Re: How to add a step to the 'App' installer which installs the attached certificate (*.device.weir)

Will this work for .cer extension as well.
In the Parameter do we need to give as -appDir "[APPDIR]" or the actual certificate file.
if i am trying with (.cer) extension file it gives error - Script output: "ERROR: The certificate file could not be found."
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: How to add a step to the 'App' installer which installs the attached certificate (*.device.weir)

Hello Abhinay,

Please keep in mind that I have tested this using a .pfx certificate, that being the reason why I have used the "Import-PfxCertificate" cmdlet.

That is also the reason why I have highlighted (with the red mark) the "Import-PfxCertificate". In your case, you should use the "Import-Certificate" cmdlet instead.

Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Abhinay
Posts: 36
Joined: Wed Feb 27, 2019 9:33 am

Re: How to add a step to the 'App' installer which installs the attached certificate (*.device.weir)

I followed the steps and configured as per the screen shot provided by you, but i am getting
Return code: 574
Script output: "ERROR: The certificate file could not be found."
How to resolve this

I resolved this by giving physical path and it worked .... Thank you.. :lol:
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: How to add a step to the 'App' installer which installs the attached certificate (*.device.weir)

You are always welcome, Abhinay.

Glad I could help.

All the best,
Catalin
:D
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”