mns45 mns45 - 3 months ago 16
Java Question

Bouncycastle Java - Generate a tst file from TimestampToken

I am new on Bouncycastle. I can get timeStampToken from TSA server with http connection.

InputStream in = con.getInputStream();
TimeStampResp resp = TimeStampResp.getInstance(new ASN1InputStream(in).readObject());
TimeStampResponse response = new TimeStampResponse(resp);
response.validate(timeStampRequest);


InputStream in = con.getInputStream();
TimeStampResp resp = TimeStampResp.getInstance(new ASN1InputStream(in).readObject());

TimeStampResponse response = new TimeStampResponse(resp);
response.validate(timeStampRequest);


Next, I must generate a file from the TimeStampResponse object. The generated files with other client applications has CRL / OCSP url informations but my file does not have this informations. How can i generate this file?

FileOutputStream fos;
try {
fos = new FileOutputStream(
"C:/FORM-003.pdf.tst");
fos.write(response.getEncoded());
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}


Thanks for your helps.

Answer

My timestamp request must have "certReq" attribute to get response which I want.

TimeStampRequestGenerator timeStampRequestGenerator = new TimeStampRequestGenerator();
timeStampRequestGenerator.setCertReq(true);

Thanks.

Comments