The sspi call could not see the internal exception. received message was unexpected or poorly formatted in Windows 7]

I get the following error: "the sspi call could not see the internal exception. The received message was unexpected or poorly formatted in Windows 7". I tried all possible ways, but no luck. check it out

Here is the code

        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;
        }
+4
source share
1 answer

I see that this is an old post, but I recently ran into this problem. The application may work on my Windows10 and may not work on Windows 2008r2 and 2012r2 servers. The solution gets rid of SslStream and uses libraries like openssl or bouncycastle for tls connections.

0

All Articles