apns 中的 iPhone 证书错误 对 SSPI 的调用失败 [英] iPhone certificate error in apns sharp A call to SSPI failed

查看:29
本文介绍了apns 中的 iPhone 证书错误 对 SSPI 的调用失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

i have a data service hosted in azure from which i am sending notification to iphone but while establishing connection with apns i am getting following error "A call to SSPI failed. The message received was unexpected or badly formatted." i also refered following links for the same error but still getting the error

使用 APNS 锐利的苹果推送通知C# 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);
        }

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

i have installed the needed certificates on VM also. one warning i am getting on iphone developer_identity certificate which i got from apple is that "Windows does not have enough information to verify this certificate" is there is some thing wrong with my iphone certificate. please help me i am stuck

推荐答案

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

got the solution i have just changed X509Certificate to X509Certificate2 and X509CertificateCollection to X509Certificate2Collection

这篇关于apns 中的 iPhone 证书错误 对 SSPI 的调用失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆