Usecase

Sending an Push Notification APNS framework in Java fails with certificate_unkown excpetion.

                            ApnsService service =
                                 APNS.newService()
                                 .withCert("../config/app-prod-cert.p12", "password")
                                 .withProductionDestination()
                                 .build();
                           
                            String payload =
                                APNS.newPayload()
                                .alertBody("Alerts Title.")
                                .badge(4)
                                .sound("default")
                                .build();

                            service.push(deviceToken, payload);

57114 [DefaultQuartzScheduler_Worker-1] WARN com.notnoop.apns.internal.ApnsConnectionImpl - Failed to send message com.notnoop.apns.EnhancedApnsNotification@62e06b60... trying again
javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
        at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
        at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1682)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:932)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1112)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:623)
        at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
        at java.io.OutputStream.write(OutputStream.java:58)

This was working before and stopped working all of sudden.

Investigation & Solution

Please check your App Push certificate.You can login and  verify it via Apple Developer Portal. Probably the certificate is Invalid or perhaps Expired. (It is valid for 1 year and has to be renewed).  That was the issue in my case. So I renewed the Push Cert, converted it to PEM (with public & private keys) and copied it over the old one. Finally I tested the Push Notification and it started to work again.<!>