sslstream with cipher (TLS_RSA_WITH_AES_128_CBC_SHA)

N

ntuyen01

Hi all,

I want to use the SSLStream with the cipher
(TLS_RSA_WITH_AES_128_CBC_SHA) to get the handshake with my server,
but I not sure where I can start. I do it in C# 2.0

Here is my code:

X509Store store = new X509Store(StoreName.Root,
StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly);
X509CertificateCollection cert = store.Certificates.Find
(X509FindType.FindBySubjectName, "servertest",false);

// Instantiate a TcpClient with the target server and port number
TcpClient client = new TcpClient(myserverip, 443);
Byte[] sendText = Encoding.ASCII.GetBytes("hello server, message from
client");

RemoteCertificateValidationCallback callback = new
RemoteCertificateValidationCallback(OnCertificateValidation);

SslStream stream = new SslStream(client.GetStream(), false,
callback);
stream.AuthenticateAsClient(servername, cert, SslProtocols.Tls,
false);

What do I do from here. How does I pass the cipher. How do check to
the handshake from the server. Does the cipher
(TLS_RSA_WITH_AES_128_CBC_SHA) I need to set in my test certificate.


if (stream.IsAuthenticated)
{
// Indicates whether the authentication was
successful.
Console.WriteLine("IsAuthenticated: {0}",
stream.IsAuthenticated);
// Indicates whether both the client and server
has been authenticated.
// In this example only the server is
authenticated.
Console.WriteLine("IsMutuallyAuthenticated: {0}",
stream.IsMutuallyAuthenticated);
// Indicates whether the SslStream uses data
encryption.
Console.WriteLine("IsEncrypted: {0}",
stream.IsEncrypted);
// Indicates whether the data sent is signed.
Console.WriteLine("IsSigned: {0}",
stream.IsSigned);
// Indicates whether the current side of the
connection is authenticated as a server.
Console.WriteLine("IsServer: {0}",
stream.IsServer);
}

Please help. Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top