All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.quorum.tessera.ssl.util.CertificateUtil Maven / Gradle / Ivy

There is a newer version: 0.11.0.30092019161842
Show newest version
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