javaapache-POST和SSL

javaapache-POST和SSL,java,android,apache,post,ssl,Java,Android,Apache,Post,Ssl,我试图通过SSL和Post在我的Android应用程序和PHP服务器之间建立安全连接。但是不幸的是,它没有连接到服务器,因为无法验证SSL证书 HttpPost httppost = new HttpPost("https://example.me/api/index.php"); 返回: javax.net.ssl.SSLExeption: hostname in certificate didn't match: <example.me> != <*.one.com>

我试图通过SSL和Post在我的Android应用程序PHP服务器之间建立安全连接。但是不幸的是,它没有连接到服务器,因为无法验证SSL证书

HttpPost httppost = new HttpPost("https://example.me/api/index.php");
返回:

javax.net.ssl.SSLExeption: hostname in certificate didn't match: <example.me> != <*.one.com> OR <*.one.com> or <one.com>
工作很有魅力:/


完整代码:

public static String[] getList(String user, String pass, String addArray, String removeArray){
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("https://example.me/api/index.php");

            try {

                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
                nameValuePairs.add(new BasicNameValuePair("user", user));
                nameValuePairs.add(new BasicNameValuePair("pass", pass));
                nameValuePairs.add(new BasicNameValuePair("addArray", addArray));
                nameValuePairs.add(new BasicNameValuePair("removeArray", removeArray));
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));


                ResponseHandler<String> responseHandler = new BasicResponseHandler(); 
                String ResponseBody = httpclient.execute(httppost, responseHandler);

                if(ResponseBody!=null){
                      String[] list = ResponseBody.split( Pattern.quote( ";" ) );
                      return list;
                 }else{
                      String[] error = {"empty"};
                      return error;
                 }

            } catch (ClientProtocolException e) {
                String[] error = {e.toString()};
                return error;
            } catch (IOException e) {
                String[] error = {e.toString()};
                return error;
            }
}
publicstaticstring[]getList(stringuser、stringpass、stringaddarray、stringremovearray){
HttpClient HttpClient=新的DefaultHttpClient();
HttpPost HttpPost=新的HttpPost(“https://example.me/api/index.php");
试一试{
List nameValuePairs=新的ArrayList(2);
添加(新的BasicNameValuePair(“用户”,user));
添加(新的BasicNameValuePair(“pass”,pass));
添加(新的BasicNameValuePair(“addArray”,addArray));
添加(新的BasicNameValuePair(“removeArray”,removeArray));
setEntity(新的UrlEncodedFormEntity(nameValuePairs));
ResponseHandler ResponseHandler=新BasicResponseHandler();
字符串ResponseBody=httpclient.execute(httppost,responseHandler);
if(ResponseBody!=null){
String[]list=ResponseBody.split(Pattern.quote(“;”));
退货清单;
}否则{
字符串[]错误={“空”};
返回误差;
}
}捕获(客户端协议例外e){
字符串[]错误={e.toString()};
返回误差;
}捕获(IOE异常){
字符串[]错误={e.toString()};
返回误差;
}
}
谢谢你的帮助;)



(我用example.me替换了我的DNS)

如果证书与颁发证书的域名匹配,就不会有问题。如果您无法修复此问题(您应该看到),则证书绑定到您创建证书时指定的特定域名“xxx.com”。如果您通过https向“xxx.com”以外的任何对象(如“www.xxx.com”或“completelydifferent.com”)发出请求,您将看到错误。(通配符“*.xxx.com”证书除外)在浏览器中打开url,您将看到相同类型的错误。@Alex K.确定。我的Chrome插件说证书来自类型“*.example.me”。那么这就是你所说的例外吗?键入
https://idontexist.example.me
进入浏览器,如果加载时没有ssl错误,则您有一个通配符证书,键入
https://example.me
进入浏览器如果出现ssl错误,则根域未设置为SAN,请参阅@Alex K。确定。我必须承认,所有SSL的东西让我很困惑。我发现我有一个“SNI”证书。如果证书与颁发证书的域名匹配,就不会有问题。如果您无法修复此问题(您应该看到),则证书绑定到您创建证书时指定的特定域名“xxx.com”。如果您通过https向“xxx.com”以外的任何对象(如“www.xxx.com”或“completelydifferent.com”)发出请求,您将看到错误。(通配符“*.xxx.com”证书除外)在浏览器中打开url,您将看到相同类型的错误。@Alex K.确定。我的Chrome插件说证书来自类型“*.example.me”。那么这就是你所说的例外吗?键入
https://idontexist.example.me
进入浏览器,如果加载时没有ssl错误,则您有一个通配符证书,键入
https://example.me
进入浏览器如果出现ssl错误,则根域未设置为SAN,请参阅@Alex K。确定。我必须承认,所有SSL的东西让我很困惑。我发现我有SNI证书。
public static String[] getList(String user, String pass, String addArray, String removeArray){
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("https://example.me/api/index.php");

            try {

                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
                nameValuePairs.add(new BasicNameValuePair("user", user));
                nameValuePairs.add(new BasicNameValuePair("pass", pass));
                nameValuePairs.add(new BasicNameValuePair("addArray", addArray));
                nameValuePairs.add(new BasicNameValuePair("removeArray", removeArray));
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));


                ResponseHandler<String> responseHandler = new BasicResponseHandler(); 
                String ResponseBody = httpclient.execute(httppost, responseHandler);

                if(ResponseBody!=null){
                      String[] list = ResponseBody.split( Pattern.quote( ";" ) );
                      return list;
                 }else{
                      String[] error = {"empty"};
                      return error;
                 }

            } catch (ClientProtocolException e) {
                String[] error = {e.toString()};
                return error;
            } catch (IOException e) {
                String[] error = {e.toString()};
                return error;
            }
}