2015-02-23 88 views
0

我只使用http服務,我不想支付SSL證書並且不使用自簽名證書。還有其他方法可以在我的應用程序客戶端中獲取發送推送通知。提前致謝。如何發送沒有ssl證書的android推送通知

+0

:按我在機器人GCM關注用於推送通知,這是可能的,而不具有SSL證書。 – 2015-02-23 06:50:57

+0

我嘗試GCM,但它給出錯誤消息。看我以前的帖子。 http://stackoverflow.com/questions/28647660/ssl-handshake-exception-in-android-gcm-server這裏是鏈接。 – 2015-02-23 06:54:17

+0

如果你知道發送任何鏈接或示例代碼@Born贏得 – 2015-02-23 06:57:02

回答

0

查看鏈接。我希望它能幫助你。你應該禁用你的服務器SSL然後發送推送通知。使用下面的鏈接進行參考。 1)代碼爲客戶端2)添加此代碼的服務器。

1)http://javapapers.com/android/google-cloud-messaging-gcm-for-android-and-push-notifications/ 2)http://www.nakov.com/blog/2009/07/16/disable-certificate-validation-in-java-ssl-connections/

public static void main(String[] args) throws Exception { 
    // Create a trust manager that does not validate certificate chains 
    TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() { 
      public java.security.cert.X509Certificate[] getAcceptedIssuers() { 
       return null; 
      } 
      public void checkClientTrusted(X509Certificate[] certs, String authType) { 
      } 
      public void checkServerTrusted(X509Certificate[] certs, String authType) { 
      } 
     } 
    }; 

    // Install the all-trusting trust manager 
    SSLContext sc = SSLContext.getInstance("SSL"); 
    sc.init(null, trustAllCerts, new java.security.SecureRandom()); 
    HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); 

    // Create all-trusting host name verifier 
    HostnameVerifier allHostsValid = new HostnameVerifier() { 
     public boolean verify(String hostname, SSLSession session) { 
      return true; 
     } 
    }; 

    // Install the all-trusting host verifier 
    HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid); 

    URL url = new URL("https://www.nakov.com:2083/"); 
    URLConnection con = url.openConnection(); 
    Reader reader = new InputStreamReader(con.getInputStream()); 
    while (true) { 
     int ch = reader.read(); 
     if (ch==-1) { 
      break; 
     } 
     System.out.print((char)ch); 
    } 
} 
+0

等待我只是指它。 – 2015-02-25 06:27:54