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;
}
Aggregations