Search in sources :

Example 1 with CertificateInfo

use of org.platformlayer.auth.v1.CertificateInfo in project platformlayer by platformlayer.

the class CertificateChains method toModel.

public static CertificateChainInfo toModel(X509Certificate[] chain) {
    CertificateChainInfo chainInfo = new CertificateChainInfo();
    List<CertificateInfo> certificates = chainInfo.getCertificates();
    for (X509Certificate cert : chain) {
        CertificateInfo certificateInfo = new CertificateInfo();
        certificateInfo.setSubjectDN(Certificates.getSubject(cert));
        Md5Hash hash = OpenSshUtils.getSignature(cert.getPublicKey());
        certificateInfo.setPublicKeyHash(hash.toHex());
        byte[] data = cert.getPublicKey().getEncoded();
        certificateInfo.setPublicKey(Hex.toHex(data));
        certificates.add(certificateInfo);
    }
    return chainInfo;
}
Also used : CertificateChainInfo(org.platformlayer.auth.v1.CertificateChainInfo) CertificateInfo(org.platformlayer.auth.v1.CertificateInfo) Md5Hash(com.fathomdb.hash.Md5Hash) X509Certificate(java.security.cert.X509Certificate)

Aggregations

Md5Hash (com.fathomdb.hash.Md5Hash)1 X509Certificate (java.security.cert.X509Certificate)1 CertificateChainInfo (org.platformlayer.auth.v1.CertificateChainInfo)1 CertificateInfo (org.platformlayer.auth.v1.CertificateInfo)1