The error code you said changes our troubleshooting direction. The code 0x80070005 translates directly to a standard Windows Access Denied exception. Because your certificate utility successfully verified the signature earlier, it is highly likely that the utility was run from an elevated administrative command prompt, whereas your signing tool is executing within a standard user security context that lacks permission to read the Key Storage Provider pointer. Even though the actual private key safely resides on your network-attached YubiHSM hardware, Windows still creates a local metadata file to route requests to the device, and this local pointer inherits strict administrative security permissions upon creation.
To resolve this access restriction, you need to manually adjust the permissions on the cryptographic binding. You can achieve this by opening the Local Machine Certificate Manager by typing certlm.msc into your Windows Run dialog. Once you navigate to your Personal certificates store and locate the code signing certificate, you can access the security settings by right-clicking the certificate, navigating to All Tasks, and selecting Manage Private Keys. You must explicitly add your standard Windows user account to this security list and grant it Read permissions, which allows the signing tool process to access the hardware pointer without needing full administrative elevation.
If adjusting the certificate security properties does not immediately clear the access denied error, the permission block might be occurring at the YubiHSM registry configuration level instead of the certificate store. The signing tool requires access to the YubiHSM connection parameters and authentication keys stored in your system registry to facilitate the network handshake. You should open the Registry Editor and navigate to the path HKEY_LOCAL_MACHINE\SOFTWARE\Yubico\YubiHSM\KSP to ensure your specific user account has read access to this directory and its subkeys. Granting read access here ensures the background cryptographic process can successfully retrieve the credentials needed to authenticate over the network to your hardware security module.
Hope this helps :)
VP