Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS Push Notification java server side with error "Received fatal alert: certificate_unknown"

Tags:

java

ios

javapns

When i try to send a push notification to IOS by using 'ApnsService' on java, i got error as below:

 com.notnoop.exceptions.NetworkIOException: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
    at com.notnoop.apns.internal.Utilities.wrapAndThrowAsRuntimeException(Utilities.java:269)
    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 net.penril.notification.Initializer.notificationWorker(Initializer.java:189)
    at net.penril.notification.Initializer.Initial(Initializer.java:53)
    at net.penril.notification.PushNotificationCron$Job.run(PushNotificationCron.java:12)
    at EDU.oswego.cs.dl.util.concurrent.ClockDaemon$RunLoop.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:722)
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
    at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1977)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1093)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1328)
    at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:702)
    at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:122)
    at java.io.OutputStream.write(OutputStream.java:75)
    at com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:240)
    ... 10 more

Please refer below for my source code on server side:

 ApnsService service =
         APNS.newService()
        .withCert("src/net/notification/certificate.p12", "XXXXXX")                            
        .withSandboxDestination()
        .build();

 String payload = APNS.newPayload().alertBody(record.getSendMsg()).build();
 String token = record.getRegId();
 service.push(token, payload);

I would like to ask, the certificate i used suppose to be covert to java keystore format or any solution on it?

like image 417
user3479640 Avatar asked Nov 10 '22 10:11

user3479640


1 Answers

This is Certificate issue.

  1. Check your Certificate path is correct or not.
  2. Otherwise your Certificate (certificate.p12) is not valid.
like image 120
vinod_vh Avatar answered Nov 14 '22 22:11

vinod_vh