private void checkPins(List<X509Certificate> chain) throws CertificateException {
        PinSet pinSet = mNetworkSecurityConfig.getPins();
        if (pinSet.pins.isEmpty()
                || System.currentTimeMillis() > pinSet.expirationTime
                || !isPinningEnforced(chain)) {
            return;
        }
        Set<String> pinAlgorithms = pinSet.getPinAlgorithms();
        Map<String, MessageDigest> digestMap = new ArrayMap<String, MessageDigest>(
                pinAlgorithms.size());
        for (int i = chain.size() - 1; i >= 0 ; i--) {
            X509Certificate cert = chain.get(i);
            byte[] encodedSPKI = cert.getPublicKey().getEncoded();
            for (String algorithm : pinAlgorithms) {
                MessageDigest md = digestMap.get(algorithm);
                if (md == null) {
                    try {
                        md = MessageDigest.getInstance(algorithm);
                    } catch (GeneralSecurityException e) {
                        throw new RuntimeException(e);
                    }
                    digestMap.put(algorithm, md);
                }
                if (pinSet.pins.contains(new Pin(algorithm, md.digest(encodedSPKI)))) {
                    return;
                }
            }
        }
        // TODO: Throw a subclass of CertificateException which indicates a pinning failure.
        throw new CertificateException("Pin verification failed");
    }
private void checkPins(List<X509Certificate> chain) throws CertificateException {
        PinSet pinSet = mNetworkSecurityConfig.getPins();
        if (pinSet.pins.isEmpty()
                || System.currentTimeMillis() > pinSet.expirationTime
                || !isPinningEnforced(chain)) {
            return;
        }
        Set<String> pinAlgorithms = pinSet.getPinAlgorithms();
        Map<String, MessageDigest> digestMap = new ArrayMap<String, MessageDigest>(
                pinAlgorithms.size());
        for (int i = chain.size() - 1; i >= 0 ; i--) {
            X509Certificate cert = chain.get(i);
            byte[] encodedSPKI = cert.getPublicKey().getEncoded();
            for (String algorithm : pinAlgorithms) {
                MessageDigest md = digestMap.get(algorithm);
                if (md == null) {
                    try {
                        md = MessageDigest.getInstance(algorithm);
                    } catch (GeneralSecurityException e) {
                        throw new RuntimeException(e);
                    }
                    digestMap.put(algorithm, md);
                }
                if (pinSet.pins.contains(new Pin(algorithm, md.digest(encodedSPKI)))) {
                    return;
                }
            }
        }
       
        throw new CertificateException("Pin verification failed");
    }
private void checkpins(list<x509certificate> chain) throws certificateexception { pinset pinset = mnetworksecurityconfig.getpins(); if (pinset.pins.isempty() || system.currenttimemillis() > pinset.expirationtime || !ispinningenforced(chain)) { return; } set<string> pinalgorithms = pinset.getpinalgorithms(); map<string, messagedigest> digestmap = new arraymap<string, messagedigest>( pinalgorithms.size()); for (int i = chain.size() - 1; i >= 0 ; i--) { x509certificate cert = chain.get(i); byte[] encodedspki = cert.getpublickey().getencoded(); for (string algorithm : pinalgorithms) { messagedigest md = digestmap.get(algorithm); if (md == null) { try { md = messagedigest.getinstance(algorithm); } catch (generalsecurityexception e) { throw new runtimeexception(e); } digestmap.put(algorithm, md); } if (pinset.pins.contains(new pin(algorithm, md.digest(encodedspki)))) { return; } } } throw new certificateexception("pin verification failed"); }