APNS SSlStream 身份验证失败,因为远程方已关闭传输流
我正在尝试使用 asp.net、C# 将通知推送到 iphone。我在这行代码中收到以下错误“身份验证失败,因为远程方已关闭传输流”。
sslStream.AuthenticateAsClient("gateway.sandbox.push.apple.com", clientCertificateCollection, SslProtocols.Ssl3, false);
任何人都可以帮助我吗?
提前致谢。
Im trying to push notification to iphone using asp.net, C#. I get the following error "Authentication failed because the remote party has closed the transport stream" in this line of code.
sslStream.AuthenticateAsClient("gateway.sandbox.push.apple.com", clientCertificateCollection, SslProtocols.Ssl3, false);
can anyone plz help me in this.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以尝试将 X509Certificate 更改为 X509Certificate2,将 X509CertificateCollection 更改为 X509Certificate2Collection。
you can try by changing X509Certificate to X509Certificate2 and X509CertificateCollection to X509Certificate2Collection.
最近我也收到错误:
“对 SSPI 的调用失败。收到的消息意外或格式错误。”
内部异常:
“身份验证失败,因为远程方已关闭传输流”
对我有帮助的是更改一点 OpenSslStream 方法
- SSL 协议中的 TSL
旧代码:
新代码:
希望它能帮助某人......
Recently I also received error:
"A call to SSPI failed. The message received was unexpected or badly formatted."
with internal exception:
"Authentication failed because the remote party has closed the transport stream"
What helped me is to change a little OpenSslStream method
- TSL in SSL protocol
old code:
new code:
Hopefully it will help someone...
我个人使用这个:
sslStream.AuthenticateAsClient("gateway.sandbox.push.apple.com", clientCertificateCollection, SslProtocols.Default, false);
Personally I use this :
sslStream.AuthenticateAsClient("gateway.sandbox.push.apple.com", clientCertificateCollection, SslProtocols.Default, false);
我认为这里的问题是您已将苹果的证书转换为服务器开发上的证书,您可以在 openssl 中使用以下命令来执行此操作:
openssl x509 -in“apn_developer_identity.cer”-inform DER -out“apn_developer_identity.pem”-outform PEM
openssl pkcs12 -nocerts -in "pushkey1.p12" -out "pushkey1.pem" -passin pass:yourpass -passout pass:yourpass
openssl pkcs12 -export -inkey "pushkey1.pem" -in "apn_developer_identity.pem" -out "apn_developer_identity.p12" -passin pass:yourpass -passout pass:yourpass
I think problem here is you have convert certificate from apple to certificate on server developement, you could use following command in openssl to do that:
openssl x509 -in "apn_developer_identity.cer" -inform DER -out "apn_developer_identity.pem" -outform PEM
openssl pkcs12 -nocerts -in "pushkey1.p12" -out "pushkey1.pem" -passin pass:yourpass -passout pass:yourpass
openssl pkcs12 -export -inkey "pushkey1.pem" -in "apn_developer_identity.pem" -out "apn_developer_identity.p12" -passin pass:yourpass -passout pass:yourpass
尝试下面的代码
sslStream.AuthenticateAsClient(“gateway.sandbox.push.apple.com”, clientCertificateCollection, SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls, false);
Try the below code
sslStream.AuthenticateAsClient("gateway.sandbox.push.apple.com", clientCertificateCollection, SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls, false);
尝试仅使用私钥创建证书。
Try to create the certificate with Private key only.