我正在使用notnoop APNS 0.2.3,正在努力使用证书,现在我正在努力使用SSL。
没有关于如何为库准备p12文件的文档,因此我找到了this article来指导我。
service = APNS.newService()
.withCert(mycertPath, myP12password)
.withSandboxDestination()
.build();
service.start();
service.testConnection();
service.push(listOfTokens,payload);
启动方法因以下转储
而失败09:46:16,657 INFO ~ Failed to send message Message(Token=00; Payload=)... trying again after delay
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1822)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1004)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1188)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:654)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:100)
at java.io.OutputStream.write(OutputStream.java:58)
at com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:240)
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)
我搞砸了p12档案了吗?我还缺少其他的东西吗?
[更新1] 我正在尝试以下脚本来创建和测试p12文件命令行,并且还出现连接错误,因此我可能会在证书中搞砸了。
[更新2] 我改变了脚本来创建p12文件......其他人可以从中受益。
#!/bin/sh
bold=`tput bold`
normal=`tput sgr0`
# CONVERT CERT TO PEM
echo "${bold}CONVERTING${normal} APNS..."
openssl x509 -in aps_development.cer -inform der -out aps_development.pem
openssl x509 -in aps_production.cer -inform der -out aps_production.pem
# CONVERT PRIVATE KEY P12 INTO PEM
echo "${bold}CONVERTING ${normal} private key..."
openssl pkcs12 -nocerts -out my_private.pem -in my_private.p12
# COMBINE CERTS INTO SINGLE P12
echo "${bold}COMBINING ${normal} development..."
#cat aps_development.pem my_private.pem > my_development.pem
openssl pkcs12 -export -in aps_development.pem -inkey my_private.pem -out my_development.p12
# COMBINE CERTS INTO SINGLE P12
echo "${bold}COMBINING ${normal} production..."
#cat aps_production.pem my_private.pem > my_production.pem
openssl pkcs12 -export -in aps_production.pem -inkey my_private.pem -out my_production.p12
echo "${bold}TESTING${normal}..."
# TEST IT
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert aps_development.pem -key my_private.pem
答案 0 :(得分:0)
问题是证书问题和误解“AdHoc”仅适用于生产推送服务器。