2

在爲開發pr創建推送通知提供程序時,我們正面臨以下錯誤: 我想證書有什麼問題,因爲我啓用了推送通知,然後創建了證書但我獲得了certificate_unknown錯誤?SSL證書錯誤:certificate_unknown

main, RECV TLSv1 ALERT: fatal, certificate_unknown 
main, called closeSocket() 
main, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown 
Error pushing notification(s): 
Invalid certificate chain (Received fatal alert: certificate_unknown)! Verify that the keystore you provided was produced according to specs... 
     at javapns.notification.PushNotificationManager.sendNotification(PushNotificationManager.java:359) 
     at javapns.notification.PushNotificationManager.sendNotification(PushNotificationManager.java:301) 
     at javapns.notification.PushNotificationManager.sendNotification(PushNotificationManager.java:258) 
     at javapns.Push.payload(Push.java:122) 
     at javapns.Push.alert(Push.java:36) 
     at com.applicationname.pns.PushNotification.main(PushNotification.java:31) 

//我的代碼,我使用了推送通知

/** 
* 
*/ 
package com.applicationname.pns; 

import org.json.JSONException; 

import javapns.Push; 
import javapns.devices.Device; 
import javapns.notification.Payload; 
import javapns.notification.PushNotificationManager; 
import javapns.notification.PushNotificationPayload; 


public class PushNotification 
{ 
    private static final String HOST = "gateway.sandbox.push.apple.com"; 
    private static final int PORT = 2195; 
    private static final int BADGE = 66; 
    private static String iPhoneId = "5696ee2fa44c61fd21a7987d2b1bcf57faa1603e63cb57ff204b158fb90d28a3"; 
    private static String certificate = "D:/./trunk/Development/JavaPNS/src/com/applicationname/pns/privateKey.p12"; 
    private static String passwd = "[email protected]"; 

    /** 
    * @param args 
    */ 
    public static void main(String[] args) 
    { 
     Push.alert("Hello World!", certificate, passwd, false,iPhoneId); 

     PushNotificationPayload payLoad = new PushNotificationPayload(); 

     try 
     { 
      payLoad.addAlert("Hello World!"); 
      payLoad.addBadge(10); 
     } 
     catch (JSONException e) 
     { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 

    } 


} 
+0

您能告訴我們一些代碼嗎? –

+0

我已添加源代碼。 – User97693321

+0

你得到一個'javax.net.ssl.SSLHandshakeException',但你的代碼似乎沒有包含任何網絡。您是否確定發生了與您粘貼的代碼完全相同的異常? –

回答

2

嘗試加載公鑰代替專用密鑰

private static String certificate = "D:/./trunk/Development/JavaPNS/src/com/applicationname/pns/privateKey.p12"; 

私鑰由SSL裝服務器端的套接字。

1

您應該確保遵循procedure準備在官方JavaPNS網站上記錄的證書。遵循此程序的開發人員可以獲得積極的結果。

0

我在jdk 1.7中解決了這個問題,並且在p12文件的passwd長度大於或等於6之後使用了p12。否則,會發生以下錯誤: [[1]未傳輸到標記595d8..725bf javapns.communication.exceptions.InvalidCertificateChainException:無效的證書鏈(收到致命警報:certificate_unknown)!驗證您提供的密鑰倉庫是按照規格生產的...]