c# - 对 sspi 的调用失败,看到内部异常。收到的消息是意外的或在 Windows 7 中格式错误]

标签 c# notifications push sspi

我收到以下错误消息“对 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;
        }

最佳答案

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

关于c# - 对 sspi 的调用失败,看到内部异常。收到的消息是意外的或在 Windows 7 中格式错误],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27359261/

相关文章:

c# - 如何使用 EF6 Code First 将外键属性公开给具有导航属性的现有实体

c# - C# 中 "half"(binary16) 的类型是什么?

python - Notify2 在 Python3 IDLE 中工作,但并不总是在终端中

安卓开发: disable "show notification" programmatically with root permission?

html - Web 应用推送通知

javascript - 网页无法正确加载: '"JSON"is undefined' error

android - setLatestEventInfo() 无法在 Android Studio 中解析

javascript - 创建一个数组的数组

javascript - 如何规避 float :left; behavior in a masonry layout

c# - Winforms 插件架构中的 IOC