if (args.length != 1) {
System.out.println("Usage: Spill file");
return;
}
BufferedReader in = new BufferedReader(new FileReader(args[0]));
String begin = in.readLine();
if (begin.equals("-----BEGIN CERTIFICATE-----") == false)
throw new IOException("Couldn't find certificate beginning");
String base64 = new String();
boolean trucking = true;
while (trucking) {
String line = in.readLine();
if (line.startsWith("-----")) trucking = false;
else base64 += line;
}
in.close();
byte[] certificateData = Base64.decode(base64);
X509Certificate c = X509Certificate.getInstance(certificateData);
System.out.println("Subject: " + c.getSubjectDN().getName());
System.out.println("Issuer : " + c.getIssuerDN().getName());
System.out.println("Serial number: " +
c.getSerialNumber().toString(16));
System.out.println("Valid from " + c.getNotBefore() +
" to " + c.getNotAfter());
System.out.println("Fingerprints:");
doFingerprint(certificateData, "MD5");
doFingerprint(certificateData, "SHA");