Certificat visual studio

De Banane Atomic
Révision datée du 5 octobre 2015 à 09:21 par Nicolas (discussion | contributions) (→‎Cannot import the following key file)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)
Aller à la navigationAller à la recherche

Liens

Signer une assembly tierce

Dos.svg
REM extraire la clé publique d'une clé pfx
sn -p clé.pfx clé-public.snk

REM décompiler l'assembly tierce
ildasm /all /out=ThirdParty.il ThirdParty.dll

REM renommer l'ancien ThirdParty.il pour pouvoir créer le nouveau
REM recompiler en signant partiellement
ilasm ThirdParty.il /dll /resource=ThirdParty.res /key=clé-public.snk

REM compléter le processus de signature
sn -R ThirdParty.dll clé.pfx

REM tester que l'assembly est bien signée
sn -vf ThirdParty.dll
REM Assembly 'ThirdParty.dll' is valid

Erreurs

An attempt was made to reference a token that does not exist / Failed to install key pair -- Object already exists

  • supprimer le certificat dans « certmgr.msc » → Personal → Certificates, s'il y était installé
  • importer le certificat avec le KeySpec parameter à AT_SIGNATURE au lieu de AT_KEYEXCHANGE
Dos.svg
certutil -importPFX -user xxx.pfx AT_SIGNATURE
  • exporter le certificat depuis « certmgr.msc » pour avoir un certificat avec le KeySpec parameter à AT_SIGNATURE

Cannot import the following key file

Cannot import the following key file: xxx.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_0000000000000000
Dos.svg
REM installer le certificat manuellement
sn -i xxx.pfx VS_KEY_0000000000000000

AssemblyKeyFile attribute dans le fichier AssemblyInfo.cs

AssemblyInfo.cs
[assembly: AssemblyKeyFile("xxx.pfx")]

Ne fonctionne pas, génère toujours l'erreur:

Cryptographic failure while signing assembly '...\obj\Debug\yyy.dll' -- 
'Error signing assembly -- 
The parameter is incorrect. '