How would one submit a timestamp request to a RFC 3161 Timestamp Server using PowerShell's Invoke-WebRequest?
First, I create the timestamp request:
openssl ts -query -data message.txt -cert -sha256 -no_nonce -out ts_test_msg_sha256.tsq
Then I can use this curl command to submit it to the Timestamp server. This is confirmed to work.
curl -k -H "Content-Type: application/timestamp-query" -H "Host:timestamp.digicert.com" --data-binary @ts_test_msg_sha256.tsq http://timestamp.digicert.com > ts_test_msg_sha256.tsr
I am trying to do the same thing in PowerShell, but it isnt working. This is the PowerShell command I have tried:
Invoke-WebRequest -uri http://timestamp.digicert.com -Headers @{'Host' = 'timestamp.digicert.com'; 'Content-Type' = 'application/timestamp-query'} -body "ts_test_msg_sha256.tsq" -method POST > "ts_test_msg_sha256.tsr"
And I get this error:
Invoke-WebRequest : The remote server returned an error: (404) Not Found.
What am I doing wrong? As I understand it, the PowerShell command should be the exact same as the curl command.
EDIT: The final command I used was:
Invoke-WebRequest -uri http://timestamp.digicert.com -Headers @{'Host' = 'timestamp.digicert.com'; 'Content-Type' = 'application/timestamp-query'} -infile "ts_test_msg_sha256.tsq" -method POST -outfile ts_test_msg_sha256.tsr | Out-Null