.NET SSL Client creation with Mentalis.org libraries

zachg99_at_gmail.com
Date: 06/22/05


Date: 22 Jun 2005 10:20:16 -0700

Ok, I'm sure I'm doing something wrong, i just dont know what. I'm
attemting to create a test client that connects to an existing ssl
server that runs on a socket on an unix server. It uses ssl to encrypt
the connections so I need such functionality in .NET C#.

I'm watching the log file which writes both the connection information
and requests recieved as well as the response data, yet I never see my
request get to the server. I dont see any exceptions either when i run
it. I have the close elsewhere, but when I close the connection still
nothing happens.

url is an instance of the Url class provided in the code examples by
mentalis.org.

Here is my code:

private SecureTcpClient mySecureClient;
private SecureNetworkStream mySecureNetStream;
SecureProtocol sp = SecureProtocol.Tls1 | SecureProtocol.Ssl3;
try
{
        SecurityOptions options = new SecurityOptions(sp);
        options.Certificate = null;
        options.Entity = ConnectionEnd.Client;
        options.CommonName = url.Host;
        options.VerificationType = CredentialVerification.None;
        options.Verifier = null;
        options.Flags = SecurityFlags.Default;
        options.AllowedAlgorithms = SslAlgorithms.ALL;
        mySecureClient = new SecureTcpClient(url.Host, url.Port,options);

}
catch (Exception execpt)
{
        MessageBox.Show("Exception occurred while connecting: " +
execpt.ToString());
        return;
}

try
{
        string request = "Hello";
        byte[] reqBytes = Encoding.ASCII.GetBytes(request);
        mySecureNetStream = mySecureClient.GetStream();
        mySecureNetStream.Write(reqBytes,0,reqBytes.Length);
}
catch (Exception except)
{
        MessageBox.Show("Exception occured while sending: " +
except.ToString());
        return;
}



Relevant Pages

  • Re: SSL Stops Working
    ... The server works fine for a long ... generated an exception. ... the site will stop servicing SSL ... > "The security package Microsoft Unified Security Protocol Provider ...
    (microsoft.public.inetserver.iis.security)
  • Re: http_403 error, but not for everyone
    ... A simple way to test the certificate, just to rule that out, is to browse to ... the oma ssl site in pocket explorer. ... else i might admit that it looks strange and i dont have any bell ringing... ... >> - if the server you connect to is not a frontend exchange server see this ...
    (microsoft.public.pocketpc.phone_edition)
  • Re: Media serviced password and PocketPC
    ... i dont remember server 2000, ... did you see anything w/ ssl or some type of certificate to ... or options for basic, windows auth, kerbos...blah ...
    (microsoft.public.windowsmedia.server)
  • Re: HttpWebRequest/Response problem - HELP
    ... but how can i know what is the exception? ... I can not debug the ... > server side (or i dont know how!). ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: JDBC/JSP/MySQL Code works from my local machine, but not on server
    ... it to a server, it doesn't run through. ... I dont get either the ... connected or not connected message. ... You get an exception and that would tell you what the problem ...
    (comp.lang.java.programmer)