Skip to content

common‐lib

Miko Väli edited this page Aug 9, 2018 · 1 revision

Shared classes for other libraries.

Parse certificate policies to get the EID type

byte[] certificateData = ...;

X509CertificateHolder certificate = new X509CertificateHolder(certificateData);
Extensions extensions = certificate.getExtensions();
CertificatePolicies certificatePolicies = CertificatePolicies.fromExtensions(extensions);

EIDType type = EIDType.parse(certificatePolicies);

Everything the Android application needs from a certificate is contained in Certificate class

byte[] certificateData = ...;
Certificate certificate = Certificate.create(ByteString.of(certificateData));

// EID type
EIDType type = certificate.type();

// CN field from the certificate
String commonName = certificate.commonName();

// not after time from the certificate
Instant notAfter = certificate.notAfter();

// is the certificate expired
boolean expired = certificate.expired();

// whether it is an elliptic curve certificate
boolean ellipticCurve = certificate.ellipticCurve();

// get key usage and extended key usage from the certificate
// for example crypto-lib uses these to filter recipient results 
KeyUsage keyUsage = certificate.keyUsage();
ExtendedKeyUsage extendedKeyUsage = certificate.extendedKeyUsage();

// get the X509Certificate instance
X509Certificate x509Certificate = certificate.x509Certificate();