4
votes

I have .pfx certificate bought from https://www.globalsign.co.uk/. I've signed the ClickOnce manifest of my VSTO (Excel Add-In project type in Visual Studio) project with it and everything worked. After a month of use, I've tried to rebuilding my project (that used to work) and now it gives me an error:

An error occurred while signing: Unknown error "-2147012894"

The certificate is perfectly valid and not expired and signing manually like following works perfectly: SignTool sign /f mycert.pfx /p password somefile.exe

I've tried removing all of the certificates in certmgr.msc under the Personal/Certificates path, but it didn't help.

Anyone had this kind of error before? Any suggestions?

2

2 Answers

6
votes

Suprisingly the fix was easier than expected... I simply had to open the project file and remove all of the xml tags that were related to signing an assembly. So for example:

  <PropertyGroup>
    <SignManifests>true</SignManifests>
  </PropertyGroup>
  <PropertyGroup>
    <ManifestKeyFile>mycert.pfx</ManifestKeyFile>
  </PropertyGroup>
  <PropertyGroup>
    <ManifestCertificateThumbprint>AB3S6</ManifestCertificateThumbprint>
  </PropertyGroup>
  <PropertyGroup>
    <ManifestTimestampUrl>http://timestamp.globalsign.com/scripts/timstamp.dll</ManifestTimestampUrl>
  </PropertyGroup>

After, I've simply went to Signing tab and re-added the certificate. And this worked. Hopefully this will help someone in the future.

3
votes

I would guess that the certificate being used when you build your project is not the same one you are using when signing it manually, otherwise it would work.

Go to the project properties for your project and click on the Signing tab and take a look. If you still think it's right, click "select from file" and go pick the pfx file again to force a reload, and try it again.