List of usage examples for android.net.http SslError getUrl
public String getUrl()
From source file:org.mozilla.focus.webkit.FocusWebViewClient.java
@Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.cancel();//from www .j a v a 2 s .c om // Webkit can try to load the favicon for a bad page when you set a new URL. If we then // loadErrorPage() again, webkit tries to load the favicon again. We end up in onReceivedSSlError() // again, and we get an infinite loop of reloads (we also erroneously show the favicon URL // in the toolbar, but that's less noticeable). Hence we check whether this error is from // the desired page, or a page resource: if (error.getUrl().equals(currentPageURL)) { ErrorPage.loadErrorPage(view, error.getUrl(), WebViewClient.ERROR_FAILED_SSL_HANDSHAKE); } }
From source file:com.mb.android.MainActivity.java
public void handleSslError(SslError error, final Response<Boolean> response) { final Context context = this; SslCertificate cert = error.getCertificate(); String issuedTo = cert.getIssuedTo().getDName(); String issuedBy = cert.getIssuedBy().getDName(); String issuedOn = cert.getValidNotBeforeDate().toString(); final String srch = error.getUrl() + "--" + issuedTo + "--" + issuedBy + "--" + issuedOn; final String results = getSharedPreferences(this).getString("acurls1", ""); if (StringHelper.IndexOfIgnoreCase(results, srch) != -1) { response.onResponse(true);//from www . jav a 2 s. c o m return; } final AlertDialog.Builder builder = new AlertDialog.Builder(this); String message = getResources().getString(R.string.notification_error_ssl_cert_invalid) .replace("{0}", issuedTo.replace("localhost", "Emby Server")) .replace("{1}", issuedBy.replace("localhost", "Emby Server")).replace("{2}", issuedOn); builder.setMessage(message); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { SharedPreferences settings = getSharedPreferences(context); SharedPreferences.Editor editor = settings.edit(); editor.putString("acurls1", results + "|" + srch); // Commit the edits! boolean saved = editor.commit(); response.onResponse(true); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { response.onResponse(false); } }); final AlertDialog dialog = builder.create(); dialog.show(); }