我试图使用asp.net,C#将通知推送到iphone。在这行代码中出现以下错误“验证失败,因为远程方已关闭传输流”。APNS SSlStream验证失败,因为远程方关闭了传输流
sslStream.AuthenticateAsClient(“gateway.sandbox.push.apple.com”,clientCertificateCollection,SslProtocols.Ssl3,false);
任何人都可以在这帮助我。
在此先感谢。
我试图使用asp.net,C#将通知推送到iphone。在这行代码中出现以下错误“验证失败,因为远程方已关闭传输流”。APNS SSlStream验证失败,因为远程方关闭了传输流
sslStream.AuthenticateAsClient(“gateway.sandbox.push.apple.com”,clientCertificateCollection,SslProtocols.Ssl3,false);
任何人都可以在这帮助我。
在此先感谢。
我个人使用的:
sslStream.AuthenticateAsClient( “gateway.sandbox.push.apple.com”,clientCertificateCollection,SslProtocols.Default,FALSE);
using (TcpClient client = new TcpClient())
{
client.Connect("gateway.sandbox.push.apple.com", 2195);
using (NetworkStream networkStream = client.GetStream())
{
try
{
SslStream sslStream = new SslStream(client.GetStream(), false);
try
{
sslStream.AuthenticateAsClient("gateway.sandbox.push.apple.com", "gateway.sandbox.push.apple.com", SslProtocols.Default, false);
//building messages
sslStream.Write(msg);
sslStream.close();
你可以通过改变x509证书到X509Certificate2和X509CertificateCollection到X509Certificate2Collection尝试。
最近我还收到错误: “对SSPI的调用失败,收到的消息是意外或格式错误。” 与内部异常: “验证失败,因为远程方已关闭传输流”
什么帮助我是改变一点点OpenSslStream方法 - TSL SSL协议中
旧代码:
apnsStream.AuthenticateAsClient(
this.Host, this.certificates,
System.Security.Authentication.SslProtocols.Ssl3,
false
);
新代码:
apnsStream.AuthenticateAsClient(
this.Host, this.certificates,
System.Security.Authentication.SslProtocols.Ssl3 | System.Security.Authentication.SslProtocols.Tls,
false
);
希望这将帮助别人......
有同样的问题。在我的情况下,只有将X509Certificate - > X509Certificate2,X509CertificateCollection应用于X509Certificate2Collection并添加SslProtocols.Tls标志解决了问题。所以,两个答案都是正确的,都需要解决这个问题 – Madman 2014-11-24 14:07:55
我觉得这里的问题是,你有苹果转换证书,证书上服务器的研究与开发,你可以在OpenSSL的使用下面的命令来做到这一点:
尝试下面的代码 sslStream.AuthenticateAsClient(“gateway.sandbox.push.apple.com”,clientCertificateCollection,SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls,false);
尝试仅使用私钥创建证书。
谢谢malinois。我检查了你的代码行,但它返回相同的错误。你可以发布代码和步骤来做这个使用C#的APNS。提前致谢。非常感激你的帮助。 – Kodee 2011-01-11 10:23:26