Java tutorial
//package com.java2s; //License from project: Open Source License import java.security.cert.CertificateEncodingException; import java.security.cert.X509Certificate; import android.util.Base64; public class Main { public static String serializeCert(X509Certificate cert) throws CertificateEncodingException { StringBuffer buffer = new StringBuffer(); buffer.append("-----BEGIN CERTIFICATE-----\n"); buffer.append(Base64.encodeToString(cert.getEncoded(), Base64.DEFAULT)); buffer.append("\n-----END CERTIFICATE-----"); return buffer.toString(); } }