Java Code Examples for android.net.http.SslError#SSL_DATE_INVALID

The following examples show how to use android.net.http.SslError#SSL_DATE_INVALID . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SslUtil.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Creates an SslError object from a chromium net error code.
 */
public static SslError sslErrorFromNetErrorCode(int error, SslCertificate cert, String url) {
    assert (error >= NetError.ERR_CERT_END && error <= NetError.ERR_CERT_COMMON_NAME_INVALID);
    switch(error) {
        case NetError.ERR_CERT_COMMON_NAME_INVALID:
            return new SslError(SslError.SSL_IDMISMATCH, cert, url);
        case NetError.ERR_CERT_DATE_INVALID:
            return new SslError(SslError.SSL_DATE_INVALID, cert, url);
        case NetError.ERR_CERT_AUTHORITY_INVALID:
            return new SslError(SslError.SSL_UNTRUSTED, cert, url);
        default:
            break;
    }
    // Map all other codes to SSL_INVALID.
    return new SslError(SslError.SSL_INVALID, cert, url);
}
 
Example 2
Source File: SslUtil.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Creates an SslError object from a chromium net error code.
 */
public static SslError sslErrorFromNetErrorCode(int error, SslCertificate cert, String url) {
    assert (error >= NetError.ERR_CERT_END && error <= NetError.ERR_CERT_COMMON_NAME_INVALID);
    switch(error) {
        case NetError.ERR_CERT_COMMON_NAME_INVALID:
            return new SslError(SslError.SSL_IDMISMATCH, cert, url);
        case NetError.ERR_CERT_DATE_INVALID:
            return new SslError(SslError.SSL_DATE_INVALID, cert, url);
        case NetError.ERR_CERT_AUTHORITY_INVALID:
            return new SslError(SslError.SSL_UNTRUSTED, cert, url);
        default:
            break;
    }
    // Map all other codes to SSL_INVALID.
    return new SslError(SslError.SSL_INVALID, cert, url);
}
 
Example 3
Source File: WebViewFragment.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    Date today = new Date();
    today.setTime(System.currentTimeMillis());
    if(error.getPrimaryError() == SslError.SSL_DATE_INVALID ||
            error.getPrimaryError() == SslError.SSL_IDMISMATCH ||
            error.getPrimaryError() == SslError.SSL_INVALID ||
            error.getPrimaryError() == SslError.SSL_UNTRUSTED) {
        handler.cancel();
    }
    else {
        handler.proceed();
    }
}
 
Example 4
Source File: InAppBrowser.java    From cordova-plugin-inappbrowser with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    super.onReceivedSslError(view, handler, error);
    try {
        JSONObject obj = new JSONObject();
        obj.put("type", LOAD_ERROR_EVENT);
        obj.put("url", error.getUrl());
        obj.put("code", 0);
        obj.put("sslerror", error.getPrimaryError());
        String message;
        switch (error.getPrimaryError()) {
        case SslError.SSL_DATE_INVALID:
            message = "The date of the certificate is invalid";
            break;
        case SslError.SSL_EXPIRED:
            message = "The certificate has expired";
            break;
        case SslError.SSL_IDMISMATCH:
            message = "Hostname mismatch";
            break;
        default:
        case SslError.SSL_INVALID:
            message = "A generic error occurred";
            break;
        case SslError.SSL_NOTYETVALID:
            message = "The certificate is not yet valid";
            break;
        case SslError.SSL_UNTRUSTED:
            message = "The certificate authority is not trusted";
            break;
        }
        obj.put("message", message);

        sendUpdate(obj, true, PluginResult.Status.ERROR);
    } catch (JSONException ex) {
        LOG.d(LOG_TAG, "Should never happen");
    }
    handler.cancel();
}