标题:自签名服务器证书

时间:2011-04-29 05:34:03

标签: android web-services https x509certificate

我需要在我的Android应用程序中使用“https:\”发布网络服务,但我收到“非信任服务器证书”这样的错误。

有没有解决方案?

以下是我的代码。

public static String callservice() {



        String response = "";



        HashMap<String, String> valuemap = new HashMap<String, String>();



        valuemap.put("name", "nandlal");

        valuemap.put("date_of_birth", "12-01-1986");

        valuemap.put("gender", "women");

        valuemap.put("user_name", "nandlal80.840947");

        valuemap.put("confirm_password", "qqqq");

        valuemap.put("email", nandlal@dignizant.com);

        valuemap.put("confirm_email", "nandlal@dignizant.com");

        valuemap.put("co_address", "surat");

        valuemap.put("address_information", "surat");

        valuemap.put("postcode", "45454");

        valuemap.put("country", "india");

        valuemap.put("town", "surat");

        valuemap.put("doorcode", "800");

        valuemap.put("language", "English");

        valuemap.put("telephone_home", "840947");

        valuemap.put("telephone_work", "866");

        valuemap.put("cellphone", "56656");

        valuemap.put("skype_name", "myskype");



        HttpRequest httpRequest = new HttpRequest();



        try {



              response = httpRequest

                          .doPost("https://www.buzzador.com/apps/present_software/webservice/index.php?op=Registration1",

                                      valuemap);



              System.out.println("RESPONCE :" + response);



        } catch (Exception e) {

              // TODO Auto-generated catch block

              e.printStackTrace();

              System.out.println("ERROR :" + e.toString());

              response = e.toString();

        }

        return response;



  }

1 个答案:

答案 0 :(得分:1)

由于证书是自签名的,因此android默认信任管理器不信任它。您可以按照Bob Lee教程 Android: Trusting SSL certificates 进行操作,以便在应用程序中信任您的服务器证书: