com.quorum.tessera.ssl.util.CertificateUtil Maven / Gradle / Ivy
package com.quorum.tessera.ssl.util;
import javax.xml.bind.DatatypeConverter;
import java.security.MessageDigest;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
public interface CertificateUtil {
default String thumbPrint(final X509Certificate certificate) throws CertificateException {
try {
final byte[] encoded = certificate.getEncoded();
return DatatypeConverter.printHexBinary(
MessageDigest.getInstance("SHA-1").digest(encoded)).toLowerCase();
} catch (Exception ex) {
throw new CertificateException("Cannot generate thumbprint for this certificate. Cause by ", ex);
}
}
static CertificateUtil create() {
return new CertificateUtil() {
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy