The following error may occur when building projects for Microsoft Visual Studio 2008 - 2015.
Error: 'Cannot import the following key file: mykey.pfx. The key file may be password protected.'
Cannot import the following key file: mykey.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_C1D3ACB8FBF1AGK4
sn -i 'c:\\Pathtofile\\.pfx' VS_KEY_C1D3ACB8FBF1AGK4
”An attempt was made to reference a token that does not exist” > You can simply ignore this message.
> openssl pkcs12 -in certfile.pfx -out backupcertfile.key
> openssl pkcs12 -export -out certfiletosignwith.pfx -keysig -in backupcertfile.key
The final solution for this issue is to give up on Visual Studio for signing purpose and use 'Signtool' instead. Check the related articles section for more information regarding this.