android.net.http.SslError#SSL_IDMISMATCH源码实例Demo

下面列出了android.net.http.SslError#SSL_IDMISMATCH 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android-chromium   文件: SslUtil.java
/**
 * 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);
}
 
源代码2 项目: android-chromium   文件: SslUtil.java
/**
 * 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);
}
 
源代码3 项目: arcusandroid   文件: WebViewFragment.java
@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();
    }
}
 
源代码4 项目: Cirrus_depricated   文件: SslErrorViewAdapter.java
@Override
public void updateErrorView(View dialogView) {
    /// clean
    dialogView.findViewById(R.id.reason_no_info_about_error).setVisibility(View.GONE);
    
    /// refresh
    if (mSslError.hasError(SslError.SSL_UNTRUSTED)) {
        dialogView.findViewById(R.id.reason_cert_not_trusted).setVisibility(View.VISIBLE);
    } else {
        dialogView.findViewById(R.id.reason_cert_not_trusted).setVisibility(View.GONE);
    }
    
    if (mSslError.hasError(SslError.SSL_EXPIRED)) {
        dialogView.findViewById(R.id.reason_cert_expired).setVisibility(View.VISIBLE);
    } else {
        dialogView.findViewById(R.id.reason_cert_expired).setVisibility(View.GONE);
    }
    
    if (mSslError.getPrimaryError() == SslError.SSL_NOTYETVALID) {
        dialogView.findViewById(R.id.reason_cert_not_yet_valid).setVisibility(View.VISIBLE);
    } else {
        dialogView.findViewById(R.id.reason_cert_not_yet_valid).setVisibility(View.GONE);
    }
    
    if (mSslError.getPrimaryError() == SslError.SSL_IDMISMATCH) {
        dialogView.findViewById(R.id.reason_hostname_not_verified).setVisibility(View.VISIBLE);
    } else {
        dialogView.findViewById(R.id.reason_hostname_not_verified).setVisibility(View.GONE);
    }
}
 
@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();
}