@Override public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { final X509Certificate leafCertificate = chain[0]; if (isPinned(leafCertificate)) { return; } // Throw a CertificateException with a meaningful message. Note that we // use CERTPLAIN, which tends to be long, so colons as separator are of // no use and most other software UIs show the "public key" without // colons (and using lowercase letters). final String pinHexString = HexUtilities.encodeToHex(leafCertificate.getEncoded()); throw new CertificateNotPinnedException("Certificate not pinned. Use 'CERTPLAIN:" + pinHexString + "' to pin this certificate. But only pin the certificate if you are sure this is the correct certificate!"); }
@Override public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { final X509Certificate leafCertificate = chain[0]; if (isPinned(leafCertificate)) { return; } // Throw a CertificateException with a meaningful message. Note that we // use CERTPLAIN, which tends to be long, so colons as separator are of // no use and most other software UIs show the "public key" without // colons (and using lowercase letters). final String pinHexString = HexUtilities.encodeToHex(leafCertificate.getEncoded()); throw new CertificateNotPinnedException("Certificate not pinned. Use 'CERTPLAIN:" + pinHexString + "' to pin this certificate. But only pin the certificate if you are sure this is the correct certificate!"); }