Created
August 13, 2015 09:35
-
-
Save dfch/53f609fd04090465767d to your computer and use it in GitHub Desktop.
TSGET - get X.509 timestamp via Windows Cmd file and utilities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ECHO OFF | |
| SETLOCAL | |
| FOR /F "tokens=* delims=?" %%I IN ('ECHO %0') DO @SET SCRIPTPATH=%%~dpI | |
| FOR /F "tokens=* delims=?" %%I IN ('ECHO %SCRIPTPATH%') DO @SET SCRIPTPATH=%%~I | |
| FOR /F "tokens=* delims=?" %%I IN ('ECHO %SCRIPTPATH%') DO @SET SCRIPTPATH=%%~sI | |
| IF "\" EQU "%SCRIPTPATH:~-1%" SET SCRIPTPATH=%SCRIPTPATH:~0,-1% | |
| IF "\" EQU "%SCRIPTPATH:~0,1%" ( | |
| PUSHD "%SCRIPTPATH%" | |
| ) ELSE ( | |
| CD "%SCRIPTPATH%" | |
| ) | |
| SET OPENSSL=C:\Program Files\OpenSSL-Win64\bin\openssl.exe | |
| SET TEE=C:\cygwin\bin\tee.exe | |
| SET CURL=C:\cygwin\bin\curl.exe | |
| SET CYGWIN=%CYGWIN% nodosfilewarning | |
| SET DATAFILE=%1 | |
| SET TSREQUEST=%TEMP%\TEST0002-%RANDOM%.tsq | |
| FOR /F "tokens=1,* delims==" %%i IN ('SET DATAFILE') DO @SET TSRESPONSE=%%j.tsr | |
| SET RFC3166HOST=tsp.signtrust.de | |
| SET RFC3166URL=http://%RFC3166HOST%/tsp/dpcom | |
| "%OPENSSL%" ts -query -sha256 -data "%DATAFILE%" -cert | "%TEE%" "%TSREQUEST%" | "%CURL%" -s -S -H 'User-Agent: tsget' -H 'Host: %RFC3166HOST%' -H 'Content-Type: application/timestamp-query' -H 'Cache-Control: no-cache' -o "%TSRESPONSE%" --data-binary @- "%RFC3166URL%" | |
| IF EXIST "%TSREQUEST%" DEL "%TSREQUEST%" | |
| REM SHA-256 | |
| REM Algorithm Id: 2.16.840.1.101.3.4.2.1 (joint-iso-itu-t.16.840.1.101.3.4.2.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment