apns sharp中的iPhone证书错误对SSPI的调用失败

Rah*_*ate 7 iphone azure apple-push-notifications apns-sharp

我有一个托管在azure的数据服务,我正在向iphone发送通知,但在与apns建立连接时,我收到以下错误"对SSPI的调用失败.收到的消息是意外的或格式错误." 我也提到了相同错误的链接,但仍然收到错误

苹果推送通知与APNS sharpC#iPhone推送服务器?

        try
        {
            using (TcpClient client = new TcpClient())
            {

                try
                {
                    client.Connect("gateway.sandbox.push.apple.com", 2195);
                    Logging("TSSLProDi :Connected to Apple");
                }
                catch (Exception ex)
                {
                    Logging("TSSLProDi :" + ex.Message + "-IE-" + ex.InnerException);

                }
                using (NetworkStream networkStream = client.GetStream())
                {
                    Logging("TSSLProDi :Client connected.");

                    X509Certificate clientCertificate = new X509Certificate(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory + @"startup\certname.pfx"), "mycertpassword");
                    X509CertificateCollection clientCertificateCollection = new X509CertificateCollection(new X509Certificate[1] { clientCertificate });

                    // Create an SSL stream that will close the client's stream.
                    SslStream sslStream = new SslStream(
                        client.GetStream(),
                        false,
                        new RemoteCertificateValidationCallback(validateServerCertificate),
                        null
                        );

                    try
                    {
                        sslStream.AuthenticateAsClient("gateway.sandbox.push.apple.com", clientCertificateCollection, System.Security.Authentication.SslProtocols.Default, false);
                        Logging("TSSLProDi :slStreamAuthenticated");
                    }
                    catch (AuthenticationException ex)
                    {
                        Logging("TSSLProDi :" + "Exception: " + ex.Message.ToString());
                        if (ex.InnerException != null)
                        {
                            Logging("Inner exception: " + ex.InnerException.Message.ToString());
                        }
                        Logging("TSSLProDi :" + "Authentication failed - closing the connection.");
                        client.Close();
                        return;
                    }
                }

            }
        }
        catch (Exception ex)
        {

            Logging("TSSLProCert :" + ex.Message + "-IE-" + ex.InnerException);
        }
Run Code Online (Sandbox Code Playgroud)

我也在VM上安装了所需的证书. 一个警告我得到的iphone developer_identity证书,我从苹果得到的是"Windows没有足够的信息来验证这个证书"是我的iphone证书有一些问题.请帮帮我,我被卡住了

Rah*_*ate 6

得到了我刚刚将X509Certificate更改为X509Certificate2而X509CertificateCollection更改为X509Certificate2Collection的解决方案