细节
我使用 notnoop java-apns push mdm message,我在main函数中尝试push message没问题!但是添加到 spring mvm 在 jetty/tomcat web 上下文中运行会抛出 javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure !帮我。
使用spring mvc方法
ModelAttribute
RequestMapping("/deviceinfo")
public String pushCommand(HttpServletRequest request)
{
String id = request.getParameter("id");
Device device = deviceManager.get(new Long(id));
log.debug(device);
log.debug(device.getToken());
ApnsService service = APNS.newService().withCert( ClassLoader
.getSystemResourceAsStream("mdm_push.p12"),"123456")
.withProductionDestination().build();
String mdmPayload = APNS.newPayload().mdm(device.getToken().getPushMagic()).build();
service.push(device.getToken().getToken(), mdmPayload);
log.warn("mdmDeviceInfoCommand");
return "device form";
}
错误信息:
信息 [线程 19] ApnsConnectionImpl.run(170) | 等待错误代码 javax.net.ssl.SSLHandshakeException 时出现异常:在 sun.security.ssl.Alerts.getSSLException(Alerts.java :154) 在 sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1959) 在 sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1077) 在 sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl. java:1312) 在 sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:882) 在 sun.security.ssl.AppInputStream.read(AppInputStream.java:102) 在 java.io.InputStream.read(InputStream.java :101) 在 >com.notnoop.apns.internal.ApnsConnectionImpl$1MonitoringThread.run(ApnsConnectionImpl.java: 114) 调试 [qtp297885139-65] ApnsConnectionImpl.socket(218) | 与 APNS INFO [Thread-20] ApnsConnectionImpl.run(170) | 建立了新连接 等待错误代码 javax.net.ssl.SSLHandshakeException 时出现异常:在 sun.security.ssl.Alerts.getSSLException(Alerts.java :154) 在 sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1959) 在 sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1077) 在 sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl. java:1312) 在 sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:882) 在 sun.security.ssl.AppInputStream.read(AppInputStream.java:102) 在 java.io.InputStream.read(InputStream.java :101) 在 >com.notnoop.apns.internal。ApnsConnectionImpl$1MonitoringThread.run(ApnsConnectionImpl.java:114) 信息 [qtp297885139-65] ApnsConnectionImpl.sendMessage(264) | 发送消息失败 >Message(Id=1; Token=07BE34F5A71A; Payload={"mdm":"E101CB39-697A-4883-B303-67713DEE836E"})... >延迟 javax.net.ssl.SSLHandshakeException 后重试:收到致命警报:sun.security.ssl.Alerts.getSSLException(Alerts.java:192) 的 sun.security.ssl.Alerts.getSSLException(Alerts.java:154) 的 sun.security.ssl.SSLSocketImpl.recvAlert 的 handshake_failure (SSLSocketImpl.java:1959) 在 sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1077) 在 sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312) 在 sun.security.ssl.SSLSocketImpl。在 sun.security.ssl.AppInputStream 上读取数据记录(SSLSocketImpl.java:882)。