How to fix Exception Message: Windows cannot verify the digital signature for this file.
I have a signed exe which was being signed using a certificate present on the device and now moved to signing using Java.
The exe is responsible for toggling Windows Firewall, but after signing with my new certificate, I am getting this error
"Exception Message: Windows cannot verify the digital signature for this file. A recent hardware or software change might have installed a file that is signed incorrectly or damaged, or that might be malicious software from an unknown source "
The certificate seems to be ok here,
But when running it, throws Win32 exception.
I believe it is throwing error here in the code. Any help on this would be appreciated.
Thank you.
HCRYPTPROV hProvider;
if (!CryptAcquireContextA(&hProvider, NULL, NULL, PROV_RSA_AES, CRYPT_SILENT) &&
(GetLastError() != NTE_BAD_KEYSET || // keyset not found, try to make a new one
!CryptAcquireContextA(&hProvider, NULL, NULL, PROV_RSA_AES, CRYPT_NEWKEYSET)))
{
hr = HRESULT_FROM_WIN32(GetLastError());
DBG_PRINT(4, hr);
return hr | 0x04000000;
}