そのため、私のサイトでは、いくつかの異なる SSL 証明書を使用しています。1 つはルート ドメイン「illution.dk」用で、もう 1 つはサブドメイン「ci.illution.dk」用です。問題は、HttpPost を使用して投稿リクエストを発行し、「https://ci.illution.dk/login/device」のような URL をリクエストすると、次のようなエラー メッセージがスローされることです。
10-04 18:35:13.100: W/System.err(1680): javax.net.ssl.SSLException: hostname in certificate didn't match: <ci.illution.dk> != <www.illution.dk> OR <www.illution.dk> OR <illution.dk>
これは、illution.dk の証明書をダウンロードし、ci.illution.dk をサポートしていないことを意味していると思います。ただし、ブラウザを起動して「https://ci.illution.dk」を参照すると、すべて問題ありません。私のAndroidコードは次のとおりです。
HttpClient httpclient = new DefaultHttpClient();
//appContext.getString(R.string.base_url)
HttpPost httppost = new HttpPost("https://ci.illution.dk/login/device");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("username", params[0]));
nameValuePairs.add(new BasicNameValuePair("password", params[1]));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
httppost.addHeader("Content-Type", "application/x-www-form-urlencoded");
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
return response;
} catch (ClientProtocolException e) {
Log.d("ComputerInfo", "Error while loggin in: ClientProtocolException");
return null;
} catch (IOException e) {
Log.d("ComputerInfo", "Error while loggin in: IOException");
e.printStackTrace();
return null;
} catch (Exception e) {
Log.d("ComputerInfo", "Error while loggin in");
e.printStackTrace();
return null;
}