javabouncycastletrusted-timestamp

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.


Solution

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

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