[Mono-devel-list] Preliminary patch to change to the new SslClientStream

Carlos Guzmán Álvarez carlosga at telefonica.net
Fri Nov 21 08:37:52 EST 2003


Hello:

> I need one example of how works SslClientStream, then and when this
> patch works I'll add Ssl support. If anybody knows why this changes
> break the connection... please tell me.


SslClientStream works as a normal stream, the handshake will be 
negotiated in the first read/write orperation and after this all the 
read/write data operations will be done in SSL/TLS mode.

In PgSqlClient i'm making this for init a SSL connection to a PostgreSQL 
7.4 server:

initializeSocket();
               

if (settings.SSL)
{
    // Send SSL request message
    SSLRequest();

    if (settings.SSL)
    {
        sslStream = new SslClientStream(
            networkStream,
            settings.ServerName,
            true,
            SecurityProtocolType.Default);

        receive = new BinaryReader(sslStream);
        send    = new BinaryWriter(sslStream);
    }
}

// Send Startup message
PgOutputPacket packet = new PgOutputPacket(settings.Encoding);
                   
packet.WriteInt(PgCodes.PROTOCOL_VERSION3);
packet.WriteString("user");
packet.WriteString(settings.UserName);                   
if (settings.Database != null && settings.Database.Length > 0)
{
    packet.WriteString("database");
    packet.WriteString(settings.Database);
}
packet.Write((byte)0);    // Terminator

// Handshake protocol will be negotiated here if the connection is using 
SSL/TLS
SendData(packet.GetSimplePacketBytes());





--
Best regards

Carlos Guzmán Álvarez
Vigo-Spain




More information about the Mono-devel-list mailing list