use of com.android.org.bouncycastle.util.io.pem.PemWriter in project android_frameworks_base by ResurrectionRemix.
the class Credentials method convertToPem.
/**
* Convert objects to a PEM format which is used for
* CA_CERTIFICATE and USER_CERTIFICATE entries.
*/
public static byte[] convertToPem(Certificate... objects) throws IOException, CertificateEncodingException {
ByteArrayOutputStream bao = new ByteArrayOutputStream();
Writer writer = new OutputStreamWriter(bao, StandardCharsets.US_ASCII);
PemWriter pw = new PemWriter(writer);
for (Certificate o : objects) {
pw.writeObject(new PemObject("CERTIFICATE", o.getEncoded()));
}
pw.close();
return bao.toByteArray();
}
Aggregations