0
我知道互联网上有很多教程,但它们超出了我的知识范围,因为这是我第一次使用https。 我在这里用emmby的答案Trusting all certificates using HttpClient over HTTPS。但我不知道如何进一步实现在我连接到服务器的课上。 这里是我的HttpsConection类通过https信任自签名证书
Log.d("url", url.toString());
HttpsURLConnection httpsConnection;
Log.d("HTTP get", "get() called");
try
{
Log.v("HttpConnection", url.toString());
httpsConnection = (HttpsURLConnection) url.openConnection();
if (request != null)
{
OutputStreamWriter wr = new OutputStreamWriter(
httpsConnection.getOutputStream());
// Log.e(TAG, "created outputstream");
wr.write(request);
// Log.e(TAG, "request sent");
wr.flush();
wr.close();
} else
{
Log.e("HttpConnection", "Nothing to send to server");
}
// Execute
try
{
InputStream in = new BufferedInputStream(httpsConnection
.getInputStream());
responseString = convertStreamToString(in);
in.close();
的代码片段我有一个* .bks文件在我的资源/原材料文件夹,我被困在那里。
难道不是让所有的证书? – Bobans 2013-02-19 14:15:37
是,由* sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER)设置* – 2013-02-19 14:18:25
对不起,但我想只允许一个证书。 – Bobans 2013-02-19 15:18:14