Java tutorial
//package com.java2s; /* * oxPush2 is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. * * Copyright (c) 2014, Gluu */ import android.util.Log; import java.io.ByteArrayInputStream; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; public class Main { private static final String TAG = "cert-utils"; public static X509Certificate loadCertificate(String certificate) { try { return loadCertificate(certificate.getBytes()); } catch (Exception ex) { Log.e(TAG, "Failed to parse certificate", ex); } return null; } public static X509Certificate loadCertificate(byte[] encodedDerCertificate) throws CertificateException { X509Certificate certificate = (X509Certificate) CertificateFactory.getInstance("X.509") .generateCertificate(new ByteArrayInputStream(encodedDerCertificate)); return certificate; } }