SSL实验室分析:https://www.ssllabs.com/ssltest/analyze.html? d = amz2btc.com
我的桌面浏览器都打开了.移动Firefox打开这个很好.只有当我尝试使用移动Chrome时才会出现错误: err_cert_authority_invalid
我对SSL知之甚少,所以我无法理解SSL报告或为什么会出现这个错误.如果有人能够ELI5,那将是理想的.:)
有很多关于这个问题的帖子(javax.net.ssl.SSLPeerUnverifiedException:没有对等证书),但我找不到任何适合我的问题.
许多帖子(像这样,这个)通过允许接受所有证书来"解决"这一点,但是,当然,除了测试之外,这不是一个好的解决方案.
其他人似乎很本地化,不适合我.我真的希望有人有一些我缺乏的见解.
所以,我的问题是:我正在一台只能通过本地网络访问的服务器上进行测试,通过HTTPS连接.我需要通过浏览器拨打电话工作正常.没有抱怨证书,如果你检查证书,这一切看起来都不错.
当我试用我的Android设备时,我明白了 javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
这是调用它的代码:
StringBuilder builder = new StringBuilder();
builder.append( /* stuff goes here*/ );
httpGet.setEntity(new UrlEncodedFormEntity(nameValuePairs));
ResponseHandler<String> responseHandler = new BasicResponseHandler();
// Execute HTTP Post Request. Response body returned as a string
HttpClient httpClient = MyActivity.getHttpClient();
HttpGet httpGet = new HttpGet(builder.toString());
String jsonResponse = httpClient.execute(httpGet, responseHandler); //Line causing the Exception
Run Code Online (Sandbox Code Playgroud)
我的代码MyActivity.getHttpClient():
protected synchronized static HttpClient getHttpClient(){
if (httpClient != null)
return httpClient;
HttpParams httpParameters = new BasicHttpParams(); …Run Code Online (Sandbox Code Playgroud) 我想做一个HTTPS post方法,从我的Android应用程序发送一些数据到我的网站.
我HttpURLConnection先使用它,我的HTTP URL工作正常.我的生产网站是使用HTTPS的,我希望使用相同的POST发送HttpsURLConnection.有人可以帮我正确使用课程吗?
我在这个链接找到了一些来源:
KeyStore keyStore = ...;
TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");
tmf.init(keyStore);
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, tmf.getTrustManagers(), null);
URL url = new URL("https://www.example.com/");
HttpsURLConnection urlConnection = (HttpsURLConnection)
url.openConnection();
urlConnection.setSSLSocketFactory(context.getSocketFactory());
InputStream in = urlConnection.getInputStream();
Run Code Online (Sandbox Code Playgroud)
应该是什么价值 KeyStore keyStore = ...;?
我尝试使用相同的方式发送数据 HttpURLConnection,但我看到一些POST数据丢失或出错.
我试过这个问题的方法.我在下面粘贴我的代码
String urlParameters="dateTime=" + URLEncoder.encode(dateTime,"UTF-8")+
"&mobileNum="+URLEncoder.encode(mobileNum,"UTF-8");
URL url = new URL(myurl);
HttpsURLConnection conn;
conn=(HttpsURLConnection)url.openConnection();
// Create the SSL connection
SSLContext sc;
sc = SSLContext.getInstance("TLS");
sc.init(null, null, new …Run Code Online (Sandbox Code Playgroud)