Search code examples
javaiosmacosapple-push-notificationsjavaapns

What's the correct format for Java APNS certificate?


I'm using Java APNS (com.notnoop.apns, v0.2.3) to send Push Notifications to my iOS app. I'm creating the APNS service with the following lines:

private ApnsService createApnsService() throws IOException {
        ApnsServiceBuilder serviceBuilder = APNS.newService().withCert(certResource.getInputStream(), certPassword);
        serviceBuilder.withSandboxDestination();
        return serviceBuilder.build();
}

And receive the following exception:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.notnoop.exceptions.NetworkIOException: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure\n\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:948)\n\tat org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:647)\n\tat org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:728)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)...    <<...the stacktrace is much longer, but I've cut it of here, since nobody would read it anyway...>>

I'm guessing that my P12 certificate is incorrect. (I've also tried PEM certificate already.) At the moment I've created the P12 certificate at this way and then applied a password:

Screenshot of Keychain.app


What's the correct way to create the certificate which is compatible with Java APNS?


Solution

  • I created it as per this tutorial earlier this year and it worked perfectly.

    First follow this: http://raywenderlich.com/32960

    Then take the created .pem and then convert, as per instructions here http://code.google.com/p/apns-sharp/wiki/HowToCreatePKCS12Certificate