获取" javax.net.ssl.SSLException:收到致命警报:internal_error"尝试使用notnoop库向APNS发送推送通知时

时间:2016-12-08 10:54:54

标签: java ios ssl push-notification apple-push-notifications

我正在尝试使用notnoop java库发送推送通知,但我收到SSL异常。我也尝试在线搜索解决方案并获得一些在线工具的帮助,但是徒劳无功。

我试过" http://pushtry.com/"这显示了SSPI错误和" http://www.pushwatch.com/apns/"显示" [Errno 1] _ssl.c:510:错误:14094438:SSL例程:SSL3_READ_BYTES:tlsv1警告内部错误"。

我对ios没有想法,但我想要一个项目的解决方案。

场景:外部Java服务器应该向特定的ios应用程序发送推送通知。

我的代码:

import com.notnoop.apns.APNS;
import com.notnoop.apns.ApnsService;
import com.notnoop.apns.EnhancedApnsNotification;

public class ApnsTest {

    private ApnsService service;

    public ApnsTest() {
        try {
            String certPath = "certification_ios.p12";
            File certFile = new File(certPath);
            InputStream fis = new FileInputStream(certFile);
            service = APNS.newService().withCert(fis,"password").withSandboxDestination().build();
            sendMessage();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new ApnsTest();
    }

    public void sendMessage() {
        String payload=APNS.newPayload().alertBody("").sound("default").build();
        String deviceToken ="devicetokenof64characters";
        int now = (int) (new Date().getTime() / 1000);
        EnhancedApnsNotification notification = new EnhancedApnsNotification(EnhancedApnsNotification.INCREMENT_ID(),
                now + 60 * 60, deviceToken, payload);

        System.out.println("Sending push notification");
        service.push(deviceToken, payload);
    }

}

我得到的异常的完整堆栈跟踪如下:

com.notnoop.exceptions.NetworkIOException: javax.net.ssl.SSLException: Received fatal alert: internal_error
    at com.notnoop.apns.internal.Utilities.wrapAndThrowAsRuntimeException(Utilities.java:277)
    at com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:257)
    at com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:230)
    at com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:46)
    at com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:56)
    at com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:36)
    at com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:45)
    at ApnsTest.sendMessage(ApnsTest.java:47)
    at ApnsTest.<init>(ApnsTest.java:24)
    at ApnsTest.main(ApnsTest.java:31)
Caused by: javax.net.ssl.SSLException: Received fatal alert: internal_error
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
    at sun.security.ssl.AppOutputStream.write(Unknown Source)
    at java.io.OutputStream.write(Unknown Source)
    at com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:240)
    ... 8 more

我错过了什么或做错了什么?

密码正确,提供的设备令牌也是有效的。

0 个答案:

没有答案