not able to send push notifications because javax.net.ssl.SSLHandshakeException
See original GitHub issueI am using maven dependency to include this library <dependency> <groupId>com.notnoop.apns</groupId> <artifactId>apns</artifactId> <version>1.0.0.Beta6</version> </dependency>
Java version: J2SE-1.5
Code is pretty basic:
public static void main( String[] args )
{
ApnsService service =
APNS.newService()
.withCert("absolute-path-to-file.p12"
, "password")
.withSandboxDestination()
.build();
String payload = APNS.newPayload().alertBody("Can't be simpler than this!").build();
String token = "some token";
service.start();
service.push(token, payload);
service.stop();
}
I am getting following stacktrace:
Exception in thread “main” com.notnoop.exceptions.NetworkIOException: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake at com.notnoop.apns.internal.Utilities.wrapAndThrowAsRuntimeException(Utilities.java:284) at com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:342) at com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:312) 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 Apple.ApplePushNeetloopsAPNS.App.main(App.java:25) Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:953) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332) at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:709) 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:328) … 6 more Caused by: java.io.EOFException: SSL peer shut down incorrectly at sun.security.ssl.InputRecord.read(InputRecord.java:482) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:934) … 11 more
Issue Analytics
- State:
- Created 8 years ago
- Comments:9
Top GitHub Comments
i was also getting the same error and i tried Pusher which correctly sent the notification but then i figured out what is the issue.
The method i used to generate .p12 from my production certificate was wrong. i was selecting both Certificate and Key and then right click to export 2 files to generate .p12 file. Which infact was wrong and increasing file size. i regenerated .p12 file by right clicking only the production certificate and Voila!!! it worked.
On the other hand why pusher was working was due to the fact that pusher was using the certificate directly and not the generated .p12 file.
Hope this helps
I have tried this, but it is still the same error… NWPusher works though. Did you right click on the certificate or the private key? I remembered trying all 3 combinations, export the certificate, the private key, both cert and private key…
The complete error is always: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure