J'utilise le fichier batch suivant qui boucle un maximum de 300 fois. Il y a deux arguments, %1 est le chemin d'un dossier contenant le fichier batch, le fichier pfx et signtool.exe. %2 est le chemin complet du fichier à signer. Vous pouvez l'appeler dans votre événement post-construction Visual Studio avec quelque chose comme call "$(SolutionDir)thirdparty \signing\sign.bat " " $(SolutionDir)troisième partie \signing " "$(TargetPath)" J'ai modifié ce fichier batch pour utiliser différents serveurs d'horodatage à chaque itération. Actuellement, il utilise Comodo, Verisign, GlobalSign et Starfield. J'espère qu'il s'agit de l'ultime script de signature ;)
@echo off
REM create an array of timestamp servers...
set SERVERLIST=(http://timestamp.comodoca.com/authenticode http://timestamp.verisign.com/scripts/timestamp.dll http://timestamp.globalsign.com/scripts/timestamp.dll http://tsa.starfieldtech.com)
REM sign the file...
%1\signtool.exe sign /f %1\comodo.pfx /p videodigital %2
set timestampErrors=0
for /L %%a in (1,1,300) do (
for %%s in %SERVERLIST% do (
REM try to timestamp the file. This operation is unreliable and may need to be repeated...
%1\signtool.exe timestamp /t %%s %2
REM check the return value of the timestamping operation and retry a max of ten times...
if ERRORLEVEL 0 if not ERRORLEVEL 1 GOTO succeeded
echo Signing failed. Probably cannot find the timestamp server at %%s
set /a timestampErrors+=1
)
REM wait 2 seconds...
choice /N /T:2 /D:Y >NUL
)
REM return an error code...
echo sign.bat exit code is 1. There were %timestampErrors% timestamping errors.
exit /b 1
:succeeded
REM return a successful code...
echo sign.bat exit code is 0. There were %timestampErrors% timestamping errors.
exit /b 0
J'ai aussi mis http://timestamp.comodoca.com dans les sites de confiance (merci Vince). Je pense que cela peut être une étape importante. J'ai également mis à jour les certificats racine sur le PC.