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

标签 c# ios apple-push-notifications pushsharp

我正在尝试发送带有有效 p12 和 token 的苹果推送通知,如下所示:

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 更改为 System.Security.Authentication.SslProtocols.Ssl3 时,我得到“身份验证失败,因为远程方已关闭传输流”

如何发送 APNS? 我如何发送 apns???

最佳答案

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

关于c# - Apns c# 异常无法从传输连接读取数据现有连接被远程主机强行关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26742242/

相关文章:

ios - NSTextStorage 子类在删除字符时崩溃

IOS Web 浏览器上的 Firebase 消息传递

IOS 验证/提交到 iTunes Connect 失败

iOS - 收到推送通知后阅读

c# - ServiceStack - 将 HttpStatus 返回到 Android 设备

c# - 按下左/右键时防止焦点改变

c# - 单核中的 Plinq?

ios - 如何在 Google map Xcode 顶部显示 subview 或按钮

ios - 如何在 CloudKit 中设置对当前用户的引用?

C# - x.ToString ("D") 和 x.ToString() 之间有什么区别吗,其中 x 是 int 类型?