Apns c#exception无法从传输连接读取数据,远程主机强行关闭现有连接

时间:2014-11-04 18:21:57

标签: c# ios apple-push-notifications pushsharp

我尝试使用有效的p12和令牌发送苹果推送通知,如下所示:

void connect()
        {
            client = new TcpClient();

            //Notify we are connecting
            var eoc = this.OnConnecting;
            if (eoc != null)
                eoc(this.appleSettings.Host, this.appleSettings.Port);

            try
            {
                client.Connect(this.appleSettings.Host, this.appleSettings.Port);
            }
            catch (Exception ex)
            {
                throw new ConnectionFailureException("Connection to Host Failed", ex);
            }

            if (appleSettings.SkipSsl)
            {
                networkStream = client.GetStream();
            }
            else
            {
                stream = new SslStream(client.GetStream(), false,
                    new RemoteCertificateValidationCallback((sender, cert, chain, sslPolicyErrors) => { return true; }),
                    new LocalCertificateSelectionCallback((sender, targetHost, localCerts, remoteCert, acceptableIssuers) =>
                    {
                        return certificate;
                    }));

                try
                {
                    stream.AuthenticateAsClient(this.appleSettings.Host, this.certificates, System.Security.Authentication.SslProtocols.Tls, false);
                    //stream.AuthenticateAsClient(this.appleSettings.Host);
                }
                catch (System.Security.Authentication.AuthenticationException ex)
                {
                    throw new ConnectionFailureException("SSL Stream Failed to Authenticate as Client", ex);
                }

                if (!stream.IsMutuallyAuthenticated)
                    throw new ConnectionFailureException("SSL Stream Failed to Authenticate", null);

                if (!stream.CanWrite)
                    throw new ConnectionFailureException("SSL Stream is not Writable", null);

                networkStream = stream;
            }

            //Start reading from the stream asynchronously
            Reader();
        }

    }

当我更改了行代码:System.Security.Authentication.SslProtocols.Tls to System.Security.Authentication.SslProtocols.Ssl3我得到&#34;身份验证失败,因为远程方已关闭传输流&#34; < / p>

我如何发送APNS? 我怎么能发送apns ???

1 个答案:

答案 0 :(得分:1)

由于存在严重的安全漏洞,SSL3在上个月(2014年10月)被苹果(以及其他公司)抛弃;称为POODLE(Padding Oracle On Downgraded Legacy Encryption)。