use of org.bouncycastle.openssl.PEMWriter in project platformlayer by platformlayer.
the class CertificateUtils method toPem.
public static String toPem(Iterable<X509Certificate> certs) {
try {
StringWriter stringWriter = new StringWriter();
PEMWriter writer = new PEMWriter(stringWriter, BouncyCastleLoader.getName());
for (X509Certificate cert : certs) {
writer.writeObject(cert);
}
writer.close();
String s = stringWriter.toString();
return s;
} catch (IOException e) {
throw new IllegalArgumentException("Error serializing certificates", e);
}
}
use of org.bouncycastle.openssl.PEMWriter in project XobotOS by xamarin.
the class Credentials method convertToPem.
/**
* Convert objects to a PEM format, which is used for
* CA_CERTIFICATE, USER_CERTIFICATE, and USER_PRIVATE_KEY
* entries.
*/
public static byte[] convertToPem(Object... objects) throws IOException {
ByteArrayOutputStream bao = new ByteArrayOutputStream();
Writer writer = new OutputStreamWriter(bao, Charsets.US_ASCII);
PEMWriter pw = new PEMWriter(writer);
for (Object o : objects) {
pw.writeObject(o);
}
pw.close();
return bao.toByteArray();
}
use of org.bouncycastle.openssl.PEMWriter in project MonjaDB by Kanatoko.
the class MBCUtil method toPem.
//--------------------------------------------------------------------------------
public static String toPem(X509Certificate cert) {
ByteArrayOutputStream bo = null;
try {
bo = new ByteArrayOutputStream();
PEMWriter writer = new PEMWriter(new OutputStreamWriter(bo));
writer.writeObject(cert);
writer.flush();
writer.close();
byte[] _data = bo.toByteArray();
String pemStr = new String(_data);
return pemStr;
} catch (Exception e) {
e.printStackTrace();
return "";
} finally {
MStreamUtil.closeStream(bo);
}
}
use of org.bouncycastle.openssl.PEMWriter in project OpenAttestation by OpenAttestation.
the class TAHelper method createRSAKeyFile.
private void createRSAKeyFile(String sessionId) throws KeyStoreException, IOException, NoSuchAlgorithmException, javax.security.cert.CertificateException, java.security.cert.CertificateException {
X509Certificate cert = certFromFile(aikverifyhome + File.separator + getCertFileName(sessionId));
FileWriter fw = new FileWriter(aikverifyhome + File.separator + getRSAPubkeyFileName(sessionId));
PEMWriter pemWriter = new PEMWriter(fw);
pemWriter.writeObject(cert.getPublicKey());
pemWriter.flush();
fw.flush();
pemWriter.close();
fw.close();
}
Aggregations