TSS 서버에서 타임 스탬프를 얻어야합니다. 파일을 보내고 있습니다 (byte[]
로 변환).
하지만 응답을 얻으려고하면 NullPointerException
이 나에게 걸립니다.타임 스탬프 응답의 오류
public static void timeStampServer() throws IOException{
//String TSA_URL1 = "http://tsa.starfieldtech.com/";
String TSA_URL2 = "http://ca.signfiles.com/TSAServer.aspx";
//String TSA_URL3 = "http://timestamping.edelweb.fr/service/tsp";
try {
byte[] digest = leerByteFichero("C:\\deskSign.txt");
TimeStampRequestGenerator reqgen = new TimeStampRequestGenerator();
TimeStampRequest req = reqgen.generate(TSPAlgorithms.SHA1, digest);
byte request[] = req.getEncoded();
URL url = new URL(TSA_URL2);
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));
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();
}
}
임 3 TSA 서버와 노력하지만 그들 중 하나가 나에게 유효한 TSA를 반환
이
내 코드입니다.의 "
TimeStampResponse response = new TimeStampResponse(resp);
"에 모두 NullPointerException이 발생합니다.
TSA_URL2
내가 문제가 TSA 서버 또는 내 코드에 있는지 잘 모릅니다
java.io.IOException: Received HTTP error: 411 - Length Required.
가 발생합니다. 누구든지 나를 도울 수 있습니까?
는 그 leerByteFichero 기능은 단지 판독 대답 깜빡 파일을 만들고 바이트로 변환하십시오. – Ainur