我试图使用asp.net,C#将通知推送到iphone。我在这行代码中收到以下错误“身份验证失败,因为远程方已关闭传输流”。
sslStream.AuthenticateAsClient(“gateway.sandbox.push.apple.com”,clientCertificateCollection,SslProtocols.Ssl3,false);
任何人都可以帮助我。
提前致谢。
答案 0 :(得分:2)
您可以尝试将X509Certificate更改为X509Certificate2,将X509CertificateCollection更改为X509Certificate2Collection。
答案 1 :(得分:2)
最近我也收到了错误: “对SSPI的调用失败。收到的消息是意外的或格式错误。” 内部例外: “身份验证失败,因为远程方已关闭传输流”
帮助我的是改变一点OpenSslStream方法 - SSL协议中的TSL
旧代码:
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
);
希望它会帮助某人......
答案 2 :(得分:0)
我个人用这个:
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();
答案 3 :(得分:0)
我认为这里的问题是您在服务器开发中将Apple的转换证书转换为证书,您可以在openssl中使用以下命令来执行此操作:
答案 4 :(得分:0)
尝试以下代码 sslStream.AuthenticateAsClient(" gateway.sandbox.push.apple.com",clientCertificateCollection,SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls,false);
答案 5 :(得分:0)
尝试仅使用私钥创建证书。