BouncyCastleを使用してタイムスタンプ(RFC 3161)を要求し、http://timestamping.edelweb.fr/service/tspに接続しようとしました。私は、サーバーからTimestampResponseを取得しますが、実際の日付がないようです。タイムスタンプの応答が正しくない - BouncyCastle
これはコードです: は誰タイムスタンプのためには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)はありますか?あるいは、なぜ一般的には、これはうまくいかないのでしょうか?
私は日付を見ることを期待この行は、ちょうどにNullPointerをスロー:
System.out.println(response.getTimeStampToken().getTimeStampInfo().getGenTime());
誰もが無料で他のRFC 3161台のに準拠したタイムスタンプサーバを知っていますか?
コードを実行するには、hereからダウンロードできるbouncycastle jarsが必要です。あなたは、プロバイダ、メール、tspが必要になります。
おかげ
リンクが壊れています(404) –