接続(または、することはできません少なくとも私はそうだと思う)。私はバックエンドに精通していないので、私が致命的なルーキーの間違いをしているなら、私を許してください。 28:50.377:これはlogcat :私は、私が開発していアンドロイドアプリでmongolabs RESTインタフェースを介してのMongoDBに接続しようとしていますが、それが接続されていない、代わりにそれが例外をスローして
01-10 16
あるSystem.errの/ W(630):javax.net.ssl.SSLException:証明書内のホスト名が一致しませんでした:!= OR OR> 01 -10-10:16:28:50.388:W/System.err(630):org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:185)01-10> 16:28:50.388:W/System.errの(630):org.apache.http.conn.ssl.BrowserCompatHostnameVerifier.verify(BrowserCompatHostnameVerifier.java:54)で 以下
は私がデータベースにアクセスしてアイテムを取得するために書いたMongoLabHelperクラスの一部であります
HttpClient client;
JSONObject db;
MongoLabHelper() throws ClientProtocolException, IOException, JSONException{
client = new DefaultHttpClient();
HttpGet request = new HttpGet("https://api.mongolab.com/api/1/databases/breadcrumbs/collections/crumbs?apiKey=xxxxxxxxxxxxx");
HttpResponse response = client.execute(request);
HttpEntity entity = response.getEntity();
InputStream in = entity.getContent();
String json = in.toString();
db = new JSONObject(json);
}
public String getName(String name) throws JSONException {
JSONObject doc = db.getJSONObject(name);
return doc.getString("name");
}
とここの部分は、あなたが実際に明示的に設定SSLを処理するためにHttpClientをする必要があり、それが
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String name = "Crumb Not Available";
MongoLabHelper help;
try {
help = new MongoLabHelper();
name = help.getName("Chipotle");
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
setContentView(R.layout.breadcrumb);
TextView crumbName = (TextView) findViewById(R.id.crumb_name);
crumbName.setText(name);