【问题标题】:a call to sspi failed see inner exception. the message received was unexpected or badly formatted in windows 7]对 sspi 的调用失败,请参阅内部异常。在 Windows 7 中收到的消息是意外的或格式错误]
【发布时间】:2015-02-06 04:23:59
【问题描述】:

我收到以下错误“对 sspi 的调用失败,看到内部异常。收到的消息在 Windows 7 中是意外的或格式错误”。我尝试了所有可能的方法,但没有运气。请检查一下

这里是代码

        int port = 2195;
        String deviceID = "d6c597fcc4e3426993cf29a3a8857efbed3462d5d8e9e32c0f8b387djkdklldk";
        String hostname = "gateway.sandbox.push.apple.com";     // TEST
        //String hostname = "gateway.push.apple.com";           // REAL
        string p12FilePassword = "password";
        //        @"cert.p12";
        String certificatePath = HttpContext.Current.Server.MapPath("~/Certificate.p12");


        X509Certificate2 clientCertificate = string.IsNullOrEmpty(p12FilePassword) ? new X509Certificate2(File.ReadAllBytes(certificatePath)) : new X509Certificate2(File.ReadAllBytes(certificatePath), p12FilePassword, X509KeyStorageFlags.MachineKeySet);

        X509Certificate2Collection certificatesCollection = new X509Certificate2Collection(clientCertificate);
        TcpClient client = new TcpClient(hostname, port);

        SslStream sslStream = new SslStream(client.GetStream(), false, ValidateServerCertificate, SelectLocalCertificate);
        try
        {
            sslStream.AuthenticateAsClient(hostname, certificatesCollection, System.Security.Authentication.SslProtocols.Tls, false);
        }
        catch (Exception e)
        {
            throw (e);
            //client.Close();
            //return;
        }

【问题讨论】:

  • 内部异常是怎么说的?
  • 内部异常说“收到的消息是意外或格式错误”
  • @TanishaSayyad,我知道这是旧帖子,但是您能解决上述错误吗?如果是,您能否分享您为修复错误所做的工作。我在这里遇到同样的错误,无法使代码正常工作。谢谢。

标签: c# notifications push sspi


【解决方案1】:

我看到这是一篇旧帖子,但我最近遇到了这个问题。应用程序可以在我的 Windows10 上运行,但在 Windows server 2008r2 和 2012r2 上失败。 解决方案是摆脱 SslStream 并使用 openssl 或 bouncycastle 等库进行 tls 连接。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-10
    • 2021-06-25
    • 1970-01-01
    • 2022-12-18
    • 2018-03-13
    • 1970-01-01
    • 2016-10-21
    • 1970-01-01
    相关资源
    最近更新 更多