- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用包含 HTTPS 的 URL 访问 Web 服务,我收到无对等证书错误。以下是我收到的错误。任何人都可以帮助我吗?
08-04 12:17:52.351: I/ApplicationPackageManager(8068): cscCountry is not German : INS
08-04 12:17:52.875: D/dalvikvm(8068): GC_EXTERNAL_ALLOC freed 60K, 48% free 2801K/5379K, external 504K/517K, paused 47ms
08-04 12:18:08.453: W/KeyCharacterMap(8068): Can't open keycharmap file
08-04 12:18:08.453: W/KeyCharacterMap(8068): Error loading keycharmap file '/system/usr/keychars/sec_keypad.kcm.bin'. hw.keyboards.0.devname='sec_keypad'
08-04 12:18:08.453: W/KeyCharacterMap(8068): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
08-04 12:18:17.656: D/dalvikvm(8068): GC_CONCURRENT freed 198K, 47% free 3005K/5639K, external 617K/1023K, paused 4ms+4ms
08-04 12:18:17.695: W/System.err(8068): javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
08-04 12:18:17.718: W/System.err(8068): at org.apache.harmony.xnet.provider.jsse.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:258)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:93)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:381)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:164)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:359)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
08-04 12:18:17.718: W/System.err(8068): at com.osi.wolla.login.Login$task.doInBackground(Login.java:223)
08-04 12:18:17.718: W/System.err(8068): at com.osi.wolla.login.Login$task.doInBackground(Login.java:1)
08-04 12:18:17.718: W/System.err(8068): at android.os.AsyncTask$2.call(AsyncTask.java:185)
08-04 12:18:17.718: W/System.err(8068): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
08-04 12:18:17.718: W/System.err(8068): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
08-04 12:18:17.718: W/System.err(8068): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
08-04 12:18:17.718: W/System.err(8068): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
08-04 12:18:17.718: W/System.err(8068): at java.lang.Thread.run(Thread.java:1019)
08-04 12:18:17.718: I/System.out(8068): response....null
08-04 12:18:17.757: I/System.out(8068): url....https://mywolla.com/mobwebservices/smails_rest.php
08-04 12:18:21.687: W/webserviceCall(8068): Error for URL https://mywolla.com/mobwebservices/smails_rest.php
08-04 12:18:21.687: W/webserviceCall(8068): javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.harmony.xnet.provider.jsse.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:258)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:93)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:381)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:164)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:359)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
08-04 12:18:21.687: W/webserviceCall(8068): at com.osi.wolla.webserviceCall.getBundle(webserviceCall.java:870)
08-04 12:18:21.687: W/webserviceCall(8068): at com.osi.wolla.login.Login$task.onPostExecute(Login.java:165)
08-04 12:18:21.687: W/webserviceCall(8068): at com.osi.wolla.login.Login$task.onPostExecute(Login.java:1)
08-04 12:18:21.687: W/webserviceCall(8068): at android.os.AsyncTask.finish(AsyncTask.java:417)
08-04 12:18:21.687: W/webserviceCall(8068): at android.os.AsyncTask.access$300(AsyncTask.java:127)
08-04 12:18:21.687: W/webserviceCall(8068): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
08-04 12:18:21.687: W/webserviceCall(8068): at android.os.Handler.dispatchMessage(Handler.java:99)
08-04 12:18:21.687: W/webserviceCall(8068): at android.os.Looper.loop(Looper.java:130)
08-04 12:18:21.687: W/webserviceCall(8068): at android.app.ActivityThread.main(ActivityThread.java:3687)
08-04 12:18:21.687: W/webserviceCall(8068): at java.lang.reflect.Method.invokeNative(Native Method)
08-04 12:18:21.687: W/webserviceCall(8068): at java.lang.reflect.Method.invoke(Method.java:507)
08-04 12:18:21.687: W/webserviceCall(8068): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
08-04 12:18:21.687: W/webserviceCall(8068): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
08-04 12:18:21.687: W/webserviceCall(8068): at dalvik.system.NativeStart.main(Native Method)
08-04 12:18:21.695: D/AndroidRuntime(8068): Shutting down VM
08-04 12:18:21.695: W/dalvikvm(8068): threadid=1: thread exiting with uncaught exception (group=0x40018578)
08-04 12:18:21.695: E/AndroidRuntime(8068): FATAL EXCEPTION: main
08-04 12:18:21.695: E/AndroidRuntime(8068): java.lang.NullPointerException
08-04 12:18:21.695: E/AndroidRuntime(8068): at java.io.StringReader.<init>(StringReader.java:46)
08-04 12:18:21.695: E/AndroidRuntime(8068): at com.osi.wolla.xmlParser.parseUser(xmlParser.java:239)
08-04 12:18:21.695: E/AndroidRuntime(8068): at com.osi.wolla.login.Login$task.onPostExecute(Login.java:168)
08-04 12:18:21.695: E/AndroidRuntime(8068): at com.osi.wolla.login.Login$task.onPostExecute(Login.java:1)
08-04 12:18:21.695: E/AndroidRuntime(8068): at android.os.AsyncTask.finish(AsyncTask.java:417)
08-04 12:18:21.695: E/AndroidRuntime(8068): at android.os.AsyncTask.access$300(AsyncTask.java:127)
08-04 12:18:21.695: E/AndroidRuntime(8068): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
08-04 12:18:21.695: E/AndroidRuntime(8068): at android.os.Handler.dispatchMessage(Handler.java:99)
08-04 12:18:21.695: E/AndroidRuntime(8068): at android.os.Looper.loop(Looper.java:130)
08-04 12:18:21.695: E/AndroidRuntime(8068): at android.app.ActivityThread.main(ActivityThread.java:3687)
08-04 12:18:21.695: E/AndroidRuntime(8068): at java.lang.reflect.Method.invokeNative(Native Method)
08-04 12:18:21.695: E/AndroidRuntime(8068): at java.lang.reflect.Method.invoke(Method.java:507)
08-04 12:18:21.695: E/AndroidRuntime(8068): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
08-04 12:18:21.695: E/AndroidRuntime(8068): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
08-04 12:18:21.695: E/AndroidRuntime(8068): at dalvik.system.NativeStart.main(Native Method)
final String URL = "https://mywolla.com/mobwebservices/svalidateuser.php?wsdl";
String response = null;
try {
HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
DefaultHttpClient client = new DefaultHttpClient();
SchemeRegistry registry = new SchemeRegistry();
SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
registry.register(new Scheme("https", socketFactory, 443));
SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
DefaultHttpClient httpClient = new DefaultHttpClient(mgr, client.getParams());
// Set verifier
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
// Example send http request
HttpPost httpPost = new HttpPost(URL);
HttpResponse response1 = httpClient.execute(httpPost);
最佳答案
出于开发目的,您需要信任所有证书。使用本教程 (avilyne.com/?p=105)
将 keystore 文件添加到 res/raw 目录。并将主要 Activity 代码替换为以下内容。
package com.avilyne.android;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.params.ConnManagerPNames;
import org.apache.http.conn.params.ConnPerRouteBean;
import org.apache.http.conn.scheme.LayeredSocketFactory;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.SingleClientConnManager;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity {
private static final String SERVICE_URL =
"https://192.168.2.101:8443/RestWebServiceDemo/rest/person";
private static final String TAG = "AndroidRESTClientActivity";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void retrieveSampleData(View vw) {
String sampleURL = SERVICE_URL + "/sample";
WebServiceTask wst = new WebServiceTask(WebServiceTask.GET_TASK, this,
"GETting data...");
wst.execute(new String[] { sampleURL });
}
public void clearControls(View vw) {
EditText edFirstName = (EditText) findViewById(R.id.first_name);
EditText edLastName = (EditText) findViewById(R.id.last_name);
EditText edEmail = (EditText) findViewById(R.id.email);
edFirstName.setText("");
edLastName.setText("");
edEmail.setText("");
}
public void postData(View vw) {
EditText edFirstName = (EditText) findViewById(R.id.first_name);
EditText edLastName = (EditText) findViewById(R.id.last_name);
EditText edEmail = (EditText) findViewById(R.id.email);
String firstName = edFirstName.getText().toString();
String lastName = edLastName.getText().toString();
String email = edEmail.getText().toString();
if (firstName.equals("") || lastName.equals("") || email.equals("")) {
Toast.makeText(this, "Please enter in all required fields.",
Toast.LENGTH_LONG).show();
return;
}
WebServiceTask wst = new WebServiceTask(WebServiceTask.POST_TASK, this,
"Posting data...");
wst.addNameValuePair("firstName", firstName);
wst.addNameValuePair("lastName", lastName);
wst.addNameValuePair("email", email);
// the passed String is the URL we will POST to
wst.execute(new String[] { SERVICE_URL });
}
public void handleResponse(String response) {
EditText edFirstName = (EditText) findViewById(R.id.first_name);
EditText edLastName = (EditText) findViewById(R.id.last_name);
EditText edEmail = (EditText) findViewById(R.id.email);
edFirstName.setText("");
edLastName.setText("");
edEmail.setText("");
try {
JSONObject jso = new JSONObject(response);
String firstName = jso.getString("firstName");
String lastName = jso.getString("lastName");
String email = jso.getString("email");
edFirstName.setText(firstName);
edLastName.setText(lastName);
edEmail.setText(email);
} catch (Exception e) {
Log.e(TAG, e.getLocalizedMessage(), e);
}
}
private void hideKeyboard() {
InputMethodManager inputManager = (InputMethodManager) MainActivity.this
.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(MainActivity.this
.getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
private class WebServiceTask extends AsyncTask<String, Integer, String> {
public static final int POST_TASK = 1;
public static final int GET_TASK = 2;
private static final String TAG = "WebServiceTask";
// connection timeout, in milliseconds (waiting to connect)
// private static final int CONN_TIMEOUT = 3000;
// socket timeout, in milliseconds (waiting for data)
// private static final int SOCKET_TIMEOUT = 5000;
private int taskType = GET_TASK;
private Context mContext = null;
private String processMessage = "Processing...";
private ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
private ProgressDialog pDlg = null;
public WebServiceTask(int taskType, Context mContext,
String processMessage) {
this.taskType = taskType;
this.mContext = mContext;
this.processMessage = processMessage;
}
public void addNameValuePair(String name, String value) {
params.add(new BasicNameValuePair(name, value));
}
private void showProgressDialog() {
pDlg = new ProgressDialog(mContext);
pDlg.setMessage(processMessage);
pDlg.setProgressDrawable(mContext.getWallpaper());
pDlg.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pDlg.setCancelable(false);
pDlg.show();
}
@Override
protected void onPreExecute() {
hideKeyboard();
showProgressDialog();
}
protected String doInBackground(String... urls) {
String url = urls[0];
String result = "";
HttpResponse response = doResponse(url);
if (response == null) {
return result;
} else {
try {
result = inputStreamToString(response.getEntity()
.getContent());
} catch (IllegalStateException e) {
Log.e(TAG, e.getLocalizedMessage(), e);
} catch (IOException e) {
Log.e(TAG, e.getLocalizedMessage(), e);
}
}
return result;
}
@Override
protected void onPostExecute(String response) {
handleResponse(response);
pDlg.dismiss();
}
// Establish connection and socket (data retrieval) timeouts
/*
* private HttpParams getHttpParams() {
*
* HttpParams htpp = new BasicHttpParams();
*
* HttpConnectionParams.setConnectionTimeout(htpp, CONN_TIMEOUT);
* HttpConnectionParams.setSoTimeout(htpp, SOCKET_TIMEOUT);
*
* return htpp; }
*/
private HttpResponse doResponse(String url) {
// Use our connection and data timeouts as parameters for our
// DefaultHttpClient
// HttpClient httpclient = new DefaultHttpClient(getHttpParams());
DefaultHttpClient httpsclient = httpsClient();
HttpResponse response = null;
try {
switch (taskType) {
case POST_TASK:
HttpPost httppost = new HttpPost(url);
// Add parameters
httppost.setEntity(new UrlEncodedFormEntity(params));
response = httpsclient.execute(httppost); // httpclient.execute(httppost);
break;
case GET_TASK:
HttpGet httpget = new HttpGet(url);
response = httpsclient.execute(httpget); // httpclient.execute(httpget);
break;
}
} catch (Exception e) {
Log.e(TAG, e.getLocalizedMessage(), e);
}
return response;
}
private String inputStreamToString(InputStream is) {
String line = "";
StringBuilder total = new StringBuilder();
// Wrap a BufferedReader around the InputStream
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
try {
// Read response until the end
while ((line = rd.readLine()) != null) {
total.append(line);
}
} catch (IOException e) {
Log.e(TAG, e.getLocalizedMessage(), e);
}
// Return full string
return total.toString();
}
}
private DefaultHttpClient httpsClient() {
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory
.getSocketFactory(), 80));
schemeRegistry.register(new Scheme("https", new EasySSLSocketFactory(),
443));
HttpParams httpParams = new BasicHttpParams();
httpParams.setParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 30);
httpParams.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE,
new ConnPerRouteBean(30));
httpParams.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false);
HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);
ClientConnectionManager cm = new SingleClientConnManager(httpParams,
schemeRegistry);
return new DefaultHttpClient(cm, httpParams);
}
private class EasySSLSocketFactory implements LayeredSocketFactory {
private SSLContext sslcontext = null;
private SSLContext createEasySSLContext() throws IOException {
try {
SSLContext context = SSLContext.getInstance("TLS");
context.init(null,
new TrustManager[] { new EasyX509TrustManager(null) },
null);
return context;
} catch (Exception e) {
throw new IOException(e.getMessage());
}
}
private SSLContext getSSLContext() throws IOException {
if (this.sslcontext == null) {
this.sslcontext = createEasySSLContext();
}
return this.sslcontext;
}
/**
* @see org.apache.http.conn.scheme.SocketFactory#connectSocket(java.net.Socket,
* java.lang.String, int, java.net.InetAddress, int,
* org.apache.http.params.HttpParams)
*/
public Socket connectSocket(Socket sock, String host, int port,
InetAddress localAddress, int localPort, HttpParams params)
throws IOException, UnknownHostException,
ConnectTimeoutException {
int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
int soTimeout = HttpConnectionParams.getSoTimeout(params);
InetSocketAddress remoteAddress = new InetSocketAddress(host, port);
SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock
: createSocket());
if ((localAddress != null) || (localPort > 0)) {
// we need to bind explicitly
if (localPort < 0) {
localPort = 0; // indicates "any"
}
InetSocketAddress isa = new InetSocketAddress(localAddress,
localPort);
sslsock.bind(isa);
}
sslsock.connect(remoteAddress, connTimeout);
sslsock.setSoTimeout(soTimeout);
return sslsock;
}
/**
* @see org.apache.http.conn.scheme.SocketFactory#createSocket()
*/
public Socket createSocket() throws IOException {
return getSSLContext().getSocketFactory().createSocket();
}
/**
* @see org.apache.http.conn.scheme.SocketFactory#isSecure(java.net.Socket)
*/
public boolean isSecure(Socket socket) throws IllegalArgumentException {
return true;
}
/**
* @see org.apache.http.conn.scheme.LayeredSocketFactory#createSocket(java.net.Socket,
* java.lang.String, int, boolean)
*/
public Socket createSocket(Socket socket, String host, int port,
boolean autoClose) throws IOException, UnknownHostException {
// return getSSLContext().getSocketFactory().createSocket(socket,
// host, port, autoClose);
return getSSLContext().getSocketFactory().createSocket(socket,
host, port, autoClose);
}
// -------------------------------------------------------------------
// javadoc in org.apache.http.conn.scheme.SocketFactory says :
// Both Object.equals() and Object.hashCode() must be overridden
// for the correct operation of some connection managers
// -------------------------------------------------------------------
public boolean equals(Object obj) {
return ((obj != null) && obj.getClass().equals(
EasySSLSocketFactory.class));
}
public int hashCode() {
return EasySSLSocketFactory.class.hashCode();
}
}
private class EasyX509TrustManager implements X509TrustManager {
private X509TrustManager standardTrustManager = null;
/**
* Constructor for EasyX509TrustManager.
*/
public EasyX509TrustManager(KeyStore keystore)
throws NoSuchAlgorithmException, KeyStoreException {
super();
TrustManagerFactory factory = TrustManagerFactory
.getInstance(TrustManagerFactory.getDefaultAlgorithm());
factory.init(keystore);
TrustManager[] trustmanagers = factory.getTrustManagers();
if (trustmanagers.length == 0) {
throw new NoSuchAlgorithmException("no trust manager found");
}
this.standardTrustManager = (X509TrustManager) trustmanagers[0];
}
/**
* @see
* javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate
* [],String authType)
*/
public void checkClientTrusted(X509Certificate[] certificates,
String authType) throws CertificateException {
standardTrustManager.checkClientTrusted(certificates, authType);
}
/**
* @see
* javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate
* [],String authType)
*/
public void checkServerTrusted(X509Certificate[] certificates,
String authType) throws CertificateException {
if ((certificates != null) && (certificates.length == 1)) {
certificates[0].checkValidity();
} else {
standardTrustManager.checkServerTrusted(certificates, authType);
}
}
/**
* @see javax.net.ssl.X509TrustManager#getAcceptedIssuers()
*/
public X509Certificate[] getAcceptedIssuers() {
return this.standardTrustManager.getAcceptedIssuers();
}
}
}
关于android - 如何在android中使用https url调用webservice,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11806612/
发起 HTTPS 对话时,会生成一个随机数来为交换创建 key (或类似的东西)。我不明白这是如何防止重放攻击的。 为什么攻击者不能重复真实客户端发出的所有请求? This answer claims
要使这个简单的 HTTP header 与支持 HTTPS 的服务器通信,还需要进行哪些其他更改。 GET /index.php HTTP/1.1 Host: localhost [CR] [CR]
我想弄清楚 HTTPS 是有状态还是无状态?这是关于我构建的 RESTful API。我们最初使用 HTTP。由于 HTTP 本质上是在无状态的 TCP/IP 上工作的,因此 HTTP 是无状态的,但
我从各种来源了解到,HTTPS 握手是使用 HTTPS 中最重要的部分。我在服务器之间内部使用 POST 来传达信息,并希望为此使用 HTTPS。我想知道实际的 HTTPS 握手持续多长时间/“保持打
我想知道HTTPS是如何实现的。是数据加密还是路径加密(数据通过哪个路径)。如果有人向我提供实现细节,我将不胜感激。 最佳答案 很简单,HTTPS 使用安全套接字层来加密客户端和服务器之间传输的数据。
我是 HTTPS 技术的初学者:(。我对 HTTPS 的实现有一些疑问。 假设我有一张注册表 http://www.sitename.com/register.php 如果我想在 HTTPS 中使用它
在带有 Devise 1.51 的 Rails 3.1.1 应用程序中,我希望确认消息中使用的确认链接是 https 而不是 http。因此,在电子邮件中,“确认链接”会指向如下内容: https:/
我对 HTTPS 有疑问。我的一位前辈告诉我,Https 实际上并不使用 SSL/TLS,而只是使用它们的加密算法。他说,证书的握手过程是在传输层完成的,但实际有效负载的安全 key 加密是在应用层完
我建立了一个使用 PHP mail() 的网站。如果我在 http://上点击脚本,我可以让它成功运行,但如果我切换到 https://它就不起作用了!我使用 Godaddy 进行托管,并通过他们购买
我最近更改了域并设置了来自 https://sadlergatestoyou.co.uk 的重定向至https://www.sadlergates.co.uk但是,www.sadlergatestoy
我正在制作一个依赖于设置 http.proxyPort 和 http.proxyHost 的 Java 应用程序。有两个进程:一个是正则程序,一个是代理程序。我有一个在 http.proxyPort(
我正在开发一个 RESTful 应用程序,为此我需要将从 http 地址传入的请求重定向到它的 https 等效项。我似乎无法使用 ring/compojure 启用 https。 有人有一些有用的教
我看过很多关于重写的文章。都好。但没有一个涵盖这种具体情况。所以这是我的问题:希望你能帮忙。因为我无法让它发挥作用。 我们在domain.com(非www)上运行网站 我们已设置 ssl(因此仅限 h
我需要将大量请求自动提交到基于云的数据库接口(interface) (Intelex)。没有任何方法可以批量提交某些操作,但是提交单个请求所必需的只是让经过身份验证的用户尝试打开 Web 链接。因此,
我正在使用 https 设置一个独立的(非嵌入式) jetty 9.2.1。 我在本地机器上使用自签名证书玩了一会儿,一切顺利。 现在我正在设置一个 uat 服务器(类似于我将在生产中获得的服务器),
我对 Web 开发(从今年 1 月开始)和 Web 安全(在不到一周前开始!)都是新手,所以如果我的问题完全没有受过教育、误导或简单愚蠢,请原谅我。 我工作的公司的主要产品是一个很好的老式客户端/服务
HTTPS头是否加密到什么程度(如果有的话)? 最佳答案 它们在通过SSL传输时被加密。没有专门用于 header 的特殊加密,HTTPS对整个消息进行加密。 关于https - HTTPS head
在 HTTPS 安全模型中,最薄弱的部分是浏览器中的可信 CA 列表。有人可以通过多种方式将额外的 CA 添加到用户信任错误的人的列表中。 例如,您公司的公用计算机或 PC。管理员可能会强制您信任自己
我们最近切换到 HTTPS,当提交我们的一个表单时,Firefox 会弹出: Although this page is encrypted, the information you have ent
我知道没有愚蠢的问题,但这是:您能否在完全支持 https 的网站上通过 AdSense 或其他方式转换基于上下文的广告? 最佳答案 更新: We’ve updated the AdSense ad
我是一名优秀的程序员,十分优秀!