xObay
Posts: 21
Joined: Sat Jan 06, 2024 4:56 pm

How to use IDigitalSignature?

Wed Jan 24, 2024 11:14 pm

Hello,

Can you please give an example of how to use https://www.advancedinstaller.com/user- ... ature.html?

TIA,
Obay

Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: How to use IDigitalSignature?

Fri Jan 26, 2024 1:24 pm

Hello Obay,

Thank you for your interest in PowerShell automation support.

Please see the example below:

Code: Select all

$advinst = New-Object -ComObject AdvancedInstaller
$project = $advinst.LoadProject("D:\PS support\sample.aip")

$project.DigitalSignature.EnableSigning() = 1
$project.Save()
This example enables the Enable signing option on the Digital Signature page. The "$project.DigitalSignature.EnableSigning() = 0" will uncheck the option.

The below command sets the option to "Use file from disk":

Code: Select all

$project.DigitalSignature.SetUseFileFromDisk("D:\mycertificate.pfx")
You can see all supported fields as you type in the PowerShell interface:
PS autocomplete.png
PS autocomplete.png (24.13KiB)Viewed 5367 times

Let me know if you have any questions.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

xObay
Posts: 21
Joined: Sat Jan 06, 2024 4:56 pm

Re: How to use IDigitalSignature?

Sat Jan 27, 2024 8:56 pm

Thank you for the reply Liviu.

We are using a Yubikey which doesn't work with a PFX file. What is the approach in this case?

Regards,
Obay

Liviu
Posts: 1026
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: How to use IDigitalSignature?

Tue Jan 30, 2024 12:33 pm

Hello Obay,

As far as we know when you have a YubiKey certificate it should be available in the Personal Store of Current User. You should be able to use the SetUseFromPersonalCertificate method.

Please see the example below:

Code: Select all

$advinst = New-Object -ComObject AdvancedInstaller
$project = $advinst.LoadProject("D:\sample.aip")

$CertificatesList = $project.DigitalSignature.Certificates

foreach ($element in $CertificatesList) {
  if (($element.Thumbprint -eq "8c5a55d94c9d4d6f8b0e8f4644768f00bf65dd2c") -and ($element.Store -eq "User\MY"))
  {
  $certificate = $element

  $certificate
  }
}

$project.DigitalSignature.SetUseFromPersonalCertificate($certificate)
$project.Save()
Replace the Thumbprint with your certificate Thumbprint. The certificate is identified by Thumbprint in this case, but can use any other property of the IDigitalCertificate object.
  • String Name
    Gets the name of the certificate.
  • String Issuer
    Gets the issuer of the certificate.
  • String Subject
    Gets certificate subject.
  • String Thumbprint
    Gets certificate thumbprint.
  • String DateBegin
    Gets the first date of the valid period.
  • String DateEnd
    Gets the last date of the valid period.
Hope this helps!

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”