APNS SSlStream身份验证失败,因为远程方已关闭传输流

我试图使用asp.net,C#将通知推送到iphone。我在这行代码中收到以下错误“身份验证失败,因为远程方已关闭传输流”。 sslStream.AuthenticateAsClient(“gateway.sandbox.push.apple.com”,clientCertificateCollection,SslProtocols.Ssl3,false); 任何人都可以帮助我。 提前致谢。     
已邀请:
您可以尝试将X509Certificate更改为X509Certificate2,将X509CertificateCollection更改为X509Certificate2Collection。     
最近我也收到了错误: “对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
);
希望它会帮助某人......     
我个人用这个: 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();
    
我认为这里的问题是你有从苹果转换证书到服务器开发的证书,你可以在openssl中使用以下命令来做到这一点: 命令1: openssl x509 -in“apn_developer_identity.cer”-inform DER -out“apn_developer_identity.pem”-outform PEM 命令2: 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);     
尝试仅使用私钥创建证书。     

要回复问题请先登录注册