我有一个关于使用Spring框架的APNS库的问题。
我要执行的操作是将推送通知发送到特定设备,如果该设备在数据库中有待处理的消息,我正在使用已经被证明是有效的开发证书,这是我的代码块抛出异常
ApnsService service = APNS.newService()
.withCert(messageDevice.getMessage().getMessageWebappCert(),"superDificultPasswordYouWillNeverGuessIn1Life")
.withProductionDestination()
.build();
service.testConnection();
那是我的问题,因为我的代码抛出了此SSL异常:
com.notnoop.exceptions.NetworkIOException:javax.net.ssl.SSLException:收到致命警报: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.ApnsConnectionImpl.testConnection(ApnsConnectionImpl.java:294)
at com.notnoop.apns.internal.ApnsServiceImpl.testConnection(ApnsServiceImpl.java:57)
at com.ehecatl.noordwijk.util.MessageTask.sendMessagesSubject(MessageTask.java:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.net.ssl.SSLException: Received fatal alert: internal_error
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2023)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1125)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:747)
at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)
at java.io.OutputStream.write(OutputStream.java:75)
at com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:240)
... 17 more
我真的希望你能帮助我
最佳答案
发送生产通知时,我遇到的问题完全相同。
原来我使用的是不久前撤销的证书。
我更改为新证书,并且现在可以使用。
Apple无法识别我正在使用的客户端证书,因此中止了SSL握手。