试图通过使用BouncyCastle请求时间戳(RFC 3161)并连接到http://timestamping.edelweb.fr/service/tsp。我确实从服务器获取了TimestampResponse,但它似乎没有实际的日期。时间戳响应不正确 - BouncyCastle
这是代码:
public static void main(String[] args) {
String ocspUrl = "http://timestamping.edelweb.fr/service/tsp";
byte[] digest = "hello".getBytes();
OutputStream out = null;
try {
TimeStampRequestGenerator reqgen = new TimeStampRequestGenerator();
TimeStampRequest req = reqgen.generate(TSPAlgorithms.SHA1, digest);
byte request[] = req.getEncoded();
URL url = new URL(ocspUrl);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setDoOutput(true);
con.setDoInput(true);
con.setRequestMethod("POST");
con.setRequestProperty("Content-type", "application/timestamp-query");
con.setRequestProperty("Content-length", String.valueOf(request.length));
out = con.getOutputStream();
out.write(request);
out.flush();
if (con.getResponseCode() != HttpURLConnection.HTTP_OK) {
throw new IOException("Received HTTP error: " + con.getResponseCode() + " - " + con.getResponseMessage());
}
InputStream in = con.getInputStream();
TimeStampResp resp = TimeStampResp.getInstance(new ASN1InputStream(in).readObject());
TimeStampResponse response = new TimeStampResponse(resp);
response.validate(req);
System.out.println(response.getTimeStampToken().getTimeStampInfo().getGenTime());
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
这里的问题(S): 有没有人使用BouncyCastle的图书馆的时间戳和碰巧了解不同的状态代码,他们是什么意思?或者只是为什么这似乎不起作用。
这条线,我希望看到一个日期只是抛出一个空指针:
System.out.println(response.getTimeStampToken().getTimeStampInfo().getGenTime());
有谁知道,不含任何其他RFC 3161兼容的时间戳服务器?
如果您想运行代码,您需要可以从here下载的bouncycastle罐子。你将需要:提供者,邮件,茶匙。
感谢
的链接断开(404) – 2012-05-18 09:54:01