The specified file could not be signed

Support for all customers who have purchased a PrimalScript product license. This forum does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
DiZzyDmon
Posts: 42
Joined: Mon Aug 06, 2007 11:04 pm

The specified file could not be signed

Post by DiZzyDmon » Thu Jan 10, 2019 2:23 pm

Product, version and build: PrimalScript 2019 version 7.4.122, 64-bit
Operating system: Windows 10 1803, 64-bit

I have an Entrust code-signing certificate, which resides in my user profile's Personal > Certificates store. It is registered in PrimalScript via File > Options > Script Signing. I've been using this certificate for almost a year (since February 2018) in PrimalScript to sign my scripts. Never a problem until yesterday.

Now when I try to sign a script using PrimalScript 2019, no matter what file (.vbs or .ps1) I try to sign, even a brand new file with no code in it, as soon as I click the File > Sign button I get an error popup "The specified file could not be signed".

I do not know if this is the first time I have attempted to sign a script using the 2019 release of PrimalScript, but it might be.

I needed to rebuild my (virtual) computer anyway, to solve an unrelated problem. On this new computer, I installed PrimalScript 2019, installed the certificate, registered the certificate within PrimalScript, tried to use it. I get the same "The specified file could not be signed" error on this brand new machine.

User avatar
mxtrinidad
Site Admin
Posts: 260
Joined: Sun Mar 03, 2013 12:42 pm

Re: The specified file could not be signed

Post by mxtrinidad » Thu Jan 10, 2019 2:50 pm

Thanks for reporting the issue. Our support team will look into it and get back to you soon as possible.

User avatar
mxtrinidad
Site Admin
Posts: 260
Joined: Sun Mar 03, 2013 12:42 pm

Re: The specified file could not be signed

Post by mxtrinidad » Thu Jan 10, 2019 3:15 pm

Under the Option menu, in the "Script Settings | Script Signing" section.
Use the Certificate button to find you certificate (See image)
Cert_issue_2019-01-10_17-05-33.jpg
Cert_issue_2019-01-10_17-05-33.jpg (85.97 KiB) Viewed 606 times
Please, let us know if this solve the issue.

User avatar
DiZzyDmon
Posts: 42
Joined: Mon Aug 06, 2007 11:04 pm

Re: The specified file could not be signed

Post by DiZzyDmon » Thu Jan 10, 2019 6:45 pm

File > Options > Script Settings > Script Signing > Certificate button is the way I have always registered my script signing certificate.

When I click the button, it raises a popup showing my script signing certificate.
My script signing certificate.png
My script signing certificate.png (94.52 KiB) Viewed 594 times
I click "OK" in the popup, it goes away, and my certificate's name is listed in the "Certificate" box.

But when I click File > Sign, I get the "The specified file could not be signed" error.

User avatar
Alexander Riedel
Posts: 6835
Joined: Tue May 29, 2007 4:43 pm

Re: The specified file could not be signed

Post by Alexander Riedel » Thu Jan 10, 2019 10:43 pm

A quick test here shows it works with our certificate. I know that doesn't help you, but let's find out what is different.
If you specify a certificate in your personal store, a password should not be required. So please try after deleting that password.
Secondly, you can also try to sign without specifying ANY certificate at all. That will use the first code signing certificate in your personal store.
While this might not be the one you want to use, please try and let us know what it does.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
DiZzyDmon
Posts: 42
Joined: Mon Aug 06, 2007 11:04 pm

Re: The specified file could not be signed

Post by DiZzyDmon » Fri Jan 11, 2019 9:31 am

I blanked out the password, removed the Certificate entry, no difference.

I'm going to try reverting to an older version of PrimalScript.

User avatar
Olga_B
Site Admin
Posts: 88
Joined: Mon May 15, 2017 9:06 am

Re: The specified file could not be signed

Post by Olga_B » Fri Jan 11, 2019 2:16 pm

Could you please check if your Certificate is not expired.
We tested Signing functionality here, and with correct certificate everything works fine.
The error will be displayed if:
- certificate expired
- certificate corrupted
- you are using .pfx file and provide wrong password

Could you check the script that was signed with that certificate and check through what date this certificate is valid

User avatar
Alexander Riedel
Posts: 6835
Joined: Tue May 29, 2007 4:43 pm

Re: The specified file could not be signed

Post by Alexander Riedel » Fri Jan 11, 2019 11:26 pm

I can see the certificate is not expired on the screenshot. Please let us know how your experiment with an older build goes.
We are preparing a new build with a more detailed error message (as far as system error messages go), maybe that will give us additional clues.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
DiZzyDmon
Posts: 42
Joined: Mon Aug 06, 2007 11:04 pm

Re: The specified file could not be signed

Post by DiZzyDmon » Sat Jan 12, 2019 7:26 am

To keep this update short, my final troubleshooting round was:
  • Uninstall all Sapien software
  • Delete all leftover Sapien files and registry entries
  • Delete my script signing certificate from Certificates - Current User > Personal > Certificates
  • Restart the computer
  • Install PrimalScript 7.4.112 (released February 27, 2018)
With all that, I still immediately get "The specified file could not be signed" as soon as I click File > Sign.

This error also occurs, in the exact same manner, on my physical laptop. I know I've used that laptop in the past to sign code via PrimalScript.

Whatever's going on may not be directly related to Sapien's software. I'm going to contact the person in our IT department who obtained my Entrust script signing certificate, see if he knows anything about any changes to how our organization allows certificate checking.

User avatar
Alexander Riedel
Posts: 6835
Joined: Tue May 29, 2007 4:43 pm

Re: The specified file could not be signed

Post by Alexander Riedel » Sat Jan 12, 2019 8:13 am

There are a number of different APIs available for code signing. It is also possible that a Windows update changed/botched something.

Try this from a powershell console:
$cert = @(Get-ChildItem cert:\CurrentUser\My -codesigning)[0]
Set-AuthenticodeSignature <your_file>.ps1 $cert

and see if that also fails.
Alexander Riedel
SAPIEN Technologies, Inc.