List of usage examples for java.security.cert CertificateExpiredException toString
public String toString()
From source file:com.aivarsda.certpinninglib.HttpsPinner.java
/** * Will go over all certificate chains of the given HttpsURLConnection and * validate each one./* www . j ava 2 s. co m*/ * * @param con HttpsURLConnection that needs to be pinned. */ private boolean validateTrustedPins(HttpsURLConnection con) { boolean isSrvTrusted = false; if (con != null) { try { Certificate[] certs = con.getServerCertificates(); for (Certificate cert : certs) { // More info on X509Certificate -> http://www.ietf.org/rfc/rfc2459.txt if (cert instanceof X509Certificate) { // Checking the certificate validity, if not valid - exception will be thrown. ((X509Certificate) cert).checkValidity(); // Pinning the certificate against the trusted pins list. boolean hasTrustedPin = false; try { hasTrustedPin = hasTrustedPin((X509Certificate) cert); if (hasTrustedPin) isSrvTrusted = true; } catch (CertificateException e) { Log.e(TAG, e.toString()); } // Stop when the trusted pin is found if (hasTrustedPin && _stopPinningWhenTrusdedFound) break; } } } catch (SSLPeerUnverifiedException e) { Log.e(TAG, e.toString()); } catch (CertificateExpiredException e1) { Log.e(TAG, e1.toString()); } catch (CertificateNotYetValidException e1) { Log.e(TAG, e1.toString()); } } return isSrvTrusted; }
From source file:com.archivas.clienttools.arcutils.utils.net.SSLCertChain.java
public String getValidity() { String validity = "The cert is valid"; try {/*from ww w . ja v a2 s . co m*/ X509Certificate cert = getCertificateList().get(0); cert.checkValidity(); } catch (CertificateExpiredException e) { LOG.log(Level.WARNING, "Unexpected Exception", e); validity = e.toString(); } catch (CertificateNotYetValidException e) { LOG.log(Level.WARNING, "Unexpected Exception", e); validity = e.toString(); } return validity; }