pw.close();
return sw.getBuffer().toString();
}
public static String getCertificate() throws CertificateEncodingException {
X500PrivateCredential cred = getPrivateCredentials();
if (cred == null) {
return null;
}
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
pw.println("-----BEGIN CERTIFICATE-----");
String str = Base64.encode(cred.getCertificate().getEncoded());
int lines = str.length() / 64;
boolean lastline = (str.length() % 64) != 0;
int i;
for (i = 0; i < lines; i++) {
pw.println(str.substring(i * 64, (i * 64) + 64));