简体   繁体   English

收到致命警报:handshake_failure

[英]Received fatal alert: handshake_failure

I'm trying to send push notifications to my device using javapns library in liferay . 我正在尝试使用liferay中的 javapns库向我的设备发送推送通知。 Here's the code: 这是代码:

private void pushNotification(ActionRequest actionRequest,
            ActionResponse actionResponse) {

        try {
            System.out.println("Push");

            Push.alert("Hello World!", "ck.p12", "PASSPHRASE", false, "TOKEN");

        } catch (CommunicationException e) {
            System.out.println("CommunicationException");
            e.printStackTrace();
        } catch (KeystoreException e) {
            System.out.println("KeystoreException");
            e.printStackTrace();
        }

    }

I'm getting this error when the pushNotification is called: 调用pushNotification时出现此错误:

ERROR [PushNotificationManager:450] Delivery error: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

I've googled it but couldn't find any solution. 我用谷歌搜索但找不到任何解决方案。

Does anyone know how to solve this problem? 有谁知道如何解决这个问题?

The javax.net.ssl.SSLHandshakeException exception is usually thrown when the server you're trying to connect to does not have a valid certificate from an authorized CA. 当您尝试连接的服务器没有来自授权CA的有效证书时,通常会抛出javax.net.ssl.SSLHandshakeException异常。

Put simply, the server you're attempting to connect to is most likely using a self-signed certificate and you have to accomodate for that in your Java code. 简而言之,您尝试连接的服务器很可能使用自签名证书,您必须在Java代码中适应这一点。 This involves creating a custom KeyStore , etc. See this Stack Overflow answer for full implementation details. 这涉及创建自定义KeyStore等。有关完整的实现详细信息,请参阅 Stack Overflow答案。

Set the following properties on the server 在服务器上设置以下属性

javax.net.ssl.keyStore=../keystore/keystoreFile.jks
javax.net.ssl.keyStorePassword=yourPassword
javax.net.ssl.trustStore=../keystore/keystoreFile.jks
javax.net.ssl.trustStorePassword=yourPassword
javax.net.debug=true

you can create your keystore using 您可以使用创建密钥库

keytool -genkey -alias myKeyStore -keyalg RSA -keystore /home/aniket/keystore/keystoreFile.jks

例如,当服务器只接受TLS并且您的客户端正在尝试创建SSL连接时,会发生此算法...同时检查服务器/客户端配置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM