@Override
    public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
        if (chain.length == 0 || this.trustedFingerprints.isEmpty()) { return false; }

        final MessageDigest sha256Digest = sha256();

        // traverse up the chain until we find one whose fingerprint matches
        for (int i = 0; i < chain.length; i++) {
            final X509Certificate currentCandidate = chain[i];
            final byte[] derEncoding = currentCandidate.getEncoded();
            Fingerprint candidateFingerprint = new Fingerprint(sha256Digest.digest(derEncoding));
            if (this.trustedFingerprints.contains(candidateFingerprint)) {
                final Date currentDate = dateSupplier.get();
                currentCandidate.checkValidity(currentDate);

                // zip back down the chain and make sure everything is valid
                for(; i > 0; i--) {
                    final X509Certificate signer = chain[i];
                    final X509Certificate signed = chain[i-1];

                    verifyAndValidate(signed, signer, currentDate);
                }
                return true;
            }
        }
        return false;
    }
@Test(expected = CertificateException.class)
    public void testIsTrustedWhenDisjointedChainPresented() throws CertificateException {
        final CATrustedFingerprintTrustStrategy trustStrategy = new CATrustedFingerprintTrustStrategy(FINGERPRINT_ROOT, ()-> DATE_CERTS_VALID);
        final X509Certificate[] chain = {CERTIFICATE_SERVER, CERTIFICATE_ROOT};

        trustStrategy.isTrusted(chain, "noop");
    }