Android Certificate Create generateX509CertificateFromSignature( final Signature signature)

Here you can find the source of generateX509CertificateFromSignature( final Signature signature)

Description

generate X Certificate From Signature

License

Apache License

Declaration

private static X509Certificate generateX509CertificateFromSignature(
            final Signature signature) throws CertificateException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import android.content.pm.Signature;

import java.io.ByteArrayInputStream;

import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;

public class Main {
    private static X509Certificate generateX509CertificateFromSignature(
            final Signature signature) throws CertificateException {
        CertificateFactory certificateFactory = CertificateFactory
                .getInstance("X.509");
        ByteArrayInputStream inputStream = new ByteArrayInputStream(
                signature.toByteArray());
        X509Certificate certificate = (X509Certificate) certificateFactory
                .generateCertificate(inputStream);
        return certificate;
    }/*from   w  ww  .  j  a va  2 s  .  com*/
}

Related

  1. getCertificate()
  2. createX509CertificateFactory(String provider)
  3. verifySignature(String algorithm, Certificate cert, byte[] signature, InputStream stream)