Providing a secret key for SGEN

My .NET assembly is signed with a digital certificate from comodo. I use SGEN to create a serialization assembly. SGEN requires a key file to create such an assembly for a signed source. I tried the following lines:

sgen.exe  /force /parsableerrors /compiler:/keyfile:"mycert.pfx" "myproduct.exe"

but it tells me

SGEN: error SGEN1: Unable to generate a temporary class (result=1).
error CS1548: Cryptographic failure while signing assembly' -- 'Key file 'mycert.pfx'
- Bad Version of provider.

I tried to get .snk, which of course can be used for SGEN using SN -p mycert.pfx mycert.snk and then

sgen.exe  /force /parsableerrors /compiler:/keyfile:"mykey.snk" "myproduct.exe" 

but it tells me

SGEN: error SGEN1: Unable to generate a temporary class (result=1).
error CS1548: Cryptographic failure while signing assembly' -- 
'Key file 'mykey.snk' is missing the private key needed for signing'

I read over the internet that this is an SGEN error that cannot use pfx to sign the assembly. So what can I do? Can I extract the secret key for snk file from pfx?

+3
source share

Source: https://habr.com/ru/post/1782852/


All Articles