Driver signing: how to get MakeCert test certificates to work on x64 - windows

I'm trying to load a kernel driver that's been signed with a certificate generated by MakeCert.exe.
I followed the instructions given in the Windows Driver Kit documentation:
Sign the driver with MakeCert.exe
Verify the signature with SignTool verify /v /pa DriverFileName.sys.
Installing the cert into the test computer's Trusted Root Certification Authorities store and Trusted Publishers store, using CertMgr.exe
When I verify the signature with SignTool verify /v /pa DriverFileName.sys as described in WDK Microsoft Docs, SignTool reports that the signature is ok. I've done this on both the development computer and the test machine that is supposed to load the driver.
However, the driver doesn't actually load. The Windows CodeIntegrity log says 3004: Windows is unable to verify the image integrity of the file \Device\HarddiskVolume3\path\DriverFileName.sys because file hash could not be found on the system. 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.
I looked at this similar question. I get the same results as in that question, when I run SignTool verify /v /kp DriverFileName.sys. It says: SignTool Error: Signing Cert does not chain to a Microsoft Root Cert.
The linked question's resolution involved using a real, non-test certificate, and changing the signing setup so that it correctly chained to the Microsoft Root Certificate. I'm not yet at that stage; I just want to get my test infrastructure working "properly".
I'm interested in having the kernel load my driver, and verify the signature using the certificates that I've manually installed on the test machine. I know I can use bcdedit -set testsigning yes to disable signature validation entirely, but that seems like overkill - it will allow any signed driver to run, even if it wasn't signed with the test certificate I've installed on the machines. Is it possible to leave "testsigning" mode turned off (so the driver signature is still actually validated against an installed cert), but still use my internal self-generated MakeCert.exe test certificate?

It looks the answer is no, it's not possible.
Can I install self-signed drivers on 64-bit Windows without test mode if the self-signed CA root certificate is imported to the machine store?
The WDK documentation seems quite misleading. Installing the certificate generated by MakeCert.exe on x64 test machines seems to be entirely pointless, since the kernel never pays any attention to it.
If TESTSIGNING mode is on, the signature isn't validated, so the cert doesn't need to be installed.
If TESTSIGNING mode is off, the self-signed certificate isn't cross-signed by anything the kernel trusts, so it's not considered valid, so installing the cert doesn't help.
I'm happy to accept corrections.

Related

Supporting mutilple Windows versions and SHA1/2 certificates for .exe (applications) and .sys (drivers)

Supporting older Windows versions in apps and drivers has become much more difficult due to MS policies/actions and Certificate Authorities (issuers) following them. At this point it looks like we have to create our own self-signed SHA1 certificate and install that in the Trusted Publishers store on the end-users machine. Also, cross-signing of drivers for OSes prior to Win10 is expired and no longer available as an option. That means normal signing will need to be used and both the SHA2 and SHA1 certificate being added to the Trusted Publishers store on the end-user machine.
Catch 22 - while creating a mini certmgr type tool would be easy, there is no way to sign it for SHA1/SHA2 so the OS sees a valid signature before installing the certificates to the store. Had this utility been created a couple years it could have been signed with the SHA1/SHA2 certificates that worked at that time. certmgr (SDK 8.1) however is double-signed with SHA1/SHA2...
Now the question I have is if we were to sign the apps with the valid SHA2 EV certificate and the SHA1 self-signed certificate so that the SHA2 EV is "valid" (on Win Vista or later) and the SHA1 is "invalid" (because certificate is not in the store) will that throw off Anti-virus software or Windows itself or are they smart enough to see the SHA2 EV is "valid" so it's valid?
Same with drivers (on OSes prior to win10) (Win10 are signed by MS and while the SHA2 signature is good, the .cat file has no reference to prior OS versions - only Win10/11 are available in the MS portal)? Although drivers wouldn't be installed prior to installation of the certificate.
The question comes up because we would like to only install the SHA1 certificate to the store on old OSes (Prior to Vista) that may still use SHA1 and leave it off the newer OS versions (meaning it's invalid)? But we wonder what problems / confusion with other software / Windows could that create?
Comment: Since Windows can simply ignore SHA1, it seems there should have been no reason to prevent the CA's from issuing SHA1 certificates to make it easy to support the old OS. The same applies to the cross-signing of drivers, new versions of Windows could simply ignore those and only support the MS signed version (like it already does for Win10/11 - this would allow updates to drivers for Win7, etc..). These changes are what everyone was worried about when all the certificate requirement stuff was being proposed. They ensured everyone this wouldn't happen...

Cross Signed SHA1 cetificate for 2K/XP drivers?

Since you can no longer obtain an SHA1 certificate from the normal certificate authorities, even if you want one (because MS told them they can't), I've created a self-signed certificate following this but using sha1. I can have my CA certificate installed so certificate works fine. But for drivers, specifically 2K/XP prior to SP3, I need to cross sign it with the /ac option. Is there anyway to do that or is that whole platform now going to be hard to support any driver updates without users having to disable driver certificate requirements?

How can I get my printer driver to install on Windows 7 again

For some years we used a Comodo SHA-1 code signing certificate to sign the .cat file of our Windows printer driver. The built signed driver installed fine on XP up to Windows 10. On systems that have never seen the driver before we get the expected warning dialog asking if the user trusts us, the author of the driver.
So everything's been fine up til now.
Unfortunately, that certificate just expired, and since SHA-1 certificates are deprecated, the supplied replacement certificate is SHA-2.
The only thing that has changed in our build is the certificate. The build still produces a signed driver, and that driver behaves the same as before, i.e. absolutely fine, on Windows 8 and up. But on Windows 7, even after installing the Windows patch to make it understand SHA-2, at driver-install time we now get the scary red warning dialog saying the driver is unsigned.
My question is - is there anything I can do get the driver to install without the scary warning on Windows 7 with the Windows SHA-2 patch installed?
Once I'd added the comodo-supplied cross certificate to the Intermediate Certification Authorities store on the build machine I was able to rebuild the driver so that it installed on Win7x64 without any scary red warnings.

Code Signing Windows Drivers

I am trying to code sign a driver in Windows (drivers for a video capture card). I have the inf, cat, sys files for this driver. I have followed various Windows articles and so far am able to:
1) Download a "DER" file from GoDaddy and then create a "mycompanyinc.cer"
2) Use signtool to sign the .cat, .sys drivers
3) verified the .cat, .sys driver files are updated with digital certifiates.They correctly stated that its issued to "my company" and issued by "go daddy CA". I exported the above certificate to a ".cer" and put on a different computer
I used MMC to make sure it shows up in the Trusted Root Certificate Authorities on the system where I need to install the drivers. While there driver file shows correctly the information "issued by" ,"issued to" etc. Windows is still complaining during drivers install that the digital signature can't be verified.
Any help, direction in this matter will be greatly appreciated.
thanks!
Since 2016 Microsoft require a longer process along with an EV Code Signing Certificate for signing drivers.
They explain it in this article.

win7 64bit - manually change driver signature

I want to edit/change driver signature. Because when i start it, I got message, that signature isn't set. The only option now is to click F8 and then "Disable driver signature enforcement". But I don't really want to use this option, it's insecure. So how I can set signature for that driver? Or maybe disable driver signature enforcement for ONLY selected driver? Any ideas?
Thanks
If you purchase a code signing certificate from Verisign or Globalsign (other CAs won't work), you can remove existing signature if it's present for the driver and then apply your own signature by signing the driver file. Signing is done using signtool.exe from Windows SDK or from Windows Driver Kit. When the driver is signed, you need to include a cross-signing certificate.

Resources