Search code examples
c#.netsocketssslclass-library

What is diffrence between win form application and class library app when using SSL connection


I have a Class library application in which I'm trying to use SSL connection. but when i tried to get Authenticate As a Client to server i got the following error message:

 ssl.AuthenticateAsClient("TargetHost");

"Unable to find an entry point named 'EnumerateSecurityPackagesW' in DLL 'security.dll'."

i have done this scenario in windows application and it works fine. have any body experience about this?

            SslStream ssl = null;
            TcpClient client = new TcpClient();
            client.Connect("127.0.0.1", 9988);

            NetworkStream _NetworkStream = client.GetStream();

            IPAddress ipAdd = IPAddress.Parse("127.0.0.1");
            IPEndPoint remoteEP = new IPEndPoint(ipAdd, 9988);

            ssl = new SslStream(_NetworkStream,
                  false,new  RemoteCertificateValidationCallback(CertificateValidationCallback));

                ssl.AuthenticateAsClient("TargetHost");

Solution

  • Could you check that the security.dll library file is available to the application using your class library?

    Your first app seems to require this native library. Check if it's included along the application executable.

    The second app references your custom class library, which apparently cannot load the security.dll native dll

    "Unable to find an entry point named 'EnumerateSecurityPackagesW' in DLL 'security.dll'."
    

    You should compare the directory containing the two apps, and maybe include in the second app the absent dll.