.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

OpenSSL and SslStream

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :WPF
Hello everyone:

I have a question. Is it possible for a client written in OpenSSL (C) to talk with the server written in .NET (C# using SslStream class).

Because afaik, SslStream has methods such as AutheticateAsServer and some others which do all the low level magic for you, but in case of OpenSSL you have to take care of establishing a connection, and exchaging CipherSpec data and all other stuff involved in the handshake and the subsequest data exchanges.

Could you give me some pointers as to how to achieve this kind of interoperability?


View Complete Post

More Related Resource Links

Client using OpenSSL is not able to connect to Server using SslStream.


I have been trying to get a client written in C++ using OpenSSL 0.9.8a to connect successfully with a server written in C# using the SslStream class in .NET 4.0.  Thus far, I have been not able to get the client to successfully connect and communicate even when my server does not require a client certificate from the client.

I am getting always the following IOException " The handshake failed due to an unexpected packet format. " when i am reaching the AuthenticateAsServe() line in my server.

Any help will be highly appreciated.

sslstream client certificate validation error

Hi,I have taken server and client program from MSDN2 for sslstream. in that code client certifiacte authetication is made false  i want to enable that and do the code i have done some modification to the code but is giving error "RemoteCertificateNotAvailable" and i think that its not getting the client certificate at server side.So please can any one help me to do client server program using sslstream in which client certificate also needs to be validated.I am attaching my modified code of MSDN2Server sideusing System;using System.Collections;using System.Net;using System.Net.Sockets;using System.Net.Security;using System.Security.Authentication;using System.Text;using System.Security.Cryptography.X509Certificates;using System.IO;namespace Examples.System.Net{    public sealed class SslTcpServer     {        static X509Certificate serverCertificate = null;        // The certificate parameter specifies the name of the file         // containing the machine certificate.        // The following method is invoked by the RemoteCertificateValidationDelegate.        public static bool ValidateClientCertificate(              object sender,              X509Certificate certificate,              X509Chain chain,              SslPolicyErrors sslPolicyErrors)        {            SslPolicyErrors errors = sslPolicyErrors;            if (errors != SslPolicyErrors.None)            {

SslStream AuthenticateAsServer Problem

I have a program that uses the SslStream client/server example from MSDN Class library (http://msdn2.microsoft.com/en-us/library/system.net.security.sslstream.aspx).On the server end, upon the authenticating of the stream, it is throwing an exception.  The type of exception being thrown is a System.IO.IOException not the AuthenticationExeption that the documentation says it should throw.  (I have more information from the error stack trace if needed).The main difference between my program and the example from Microsoft is that my program is heavily multi-threaded.  I have an instance of the TCPListener created in the constructor of my class and basicly it is used a multitude of times to accept many client connections on multiple threads.  I can also include source code if needed.The program will work wonderfully for a long time, and then randomly I get the IOException error.  Once exception has been thrown, the streams continue to fail upon any more AuthenticateAsServer calls.  The only "remedy" I've found is to exit the program entirely and restart it.  I literally have the authentication work 4000-5000 times daily, but it fails up to 15-20 times per day.I am wondering if anybody might know why I am getting the IOException and any possible ways to fix it.  Is this due to something on my end? or is it due to something on the client side?Thanks in advance for the help

SslStream.Read() - Returns invalid data

Hey,I am currently attempting to implement a multi-threaded C# socket, using SSL (.pem file/certification/private key combo) server using Visual Studio C# Express.I have successfully made the client application establish a connection, and send data, which appears in plain, de-crypted text on the server - this works.However, I am 'polling' the socket to see if data is available to read.Here is some code which is appropriate:----        public void Process(int threadId)        {            int BytesRead = 0;            try            {                Master.Log("BEGIN READ");                sslStream.ReadTimeout = 5000;                BytesRead = sslStream.Read(bytes, 0, bytes.Length);                Master.Log("READ " + BytesRead + " bytes");                if ( BytesRead > 0 )                {                   // process                }             } catch (IOException e) {                Log("Caught IOException: " + e.Message);                if (e.InnerException != null)                    Log("=========> INNER IOException: " + e.InnerException.Message);         }---- Here is some console output when running the application:---------LOG: Authentication successfulLOG: BEGIN READLOG: READ 140 bytesLOG: [Thread 0] [Client 1] [Address] Client.ProcessDataReceived()Text received from client: Testing

Client/Server Authentication with SSLStream

Hello, This is my first time using MSDN.  I have a client and server application which use SSLStream to communicate over port 80.  Both the client and the server are running as Windows Services.  Everything works in my test environment (my development computer, under the OS Windows 7 Ultimate). My problem is that when I go to deploy the client and server application to their deployment environments (the server being on Windows Server 2008, and the client being on Windows Server 2003) it does not work, and I get the error: "The client and server cannot communicate, because they do not possess a common algorithm" Please note that I have installed the same certificate using the makecert commands (listed in the "Firstly" section below) In addition, when I gave up on trying to get the client to authenticate under the Windows Server 2003 computer, I moved it to a completely new/different Windows Server 2008 computer.. and then got a new error along the lines of "credentials supplied to package not recognized." If you have any experience with this issue, please advise.  I have been working on this for the past 3 days and have burnt up over 20 hours of development time. Please remember, the problem keeps happening when the Server and Client attempt to authenticate. Firstly, I used the following commands via makece

TcpClient with SSLStream via Proxy is this possible?


Hi, please help me!

I spent hours with google and msdn, but no result.


I communicate with a server with tcpclient and sslStream, and it works fine, but there is a new problem.

I have to do this with static IP adress, but cause of my service this can't possible.


So I have a server with static IP and I installed a squid proxy on it.


Can I communicate with TCPclient with SSLStream through PROXY?

How to add proxy host and port to a tcpclient with sslstream connection?

It would be very important...


Thank you very much!

Compatibality of EncrytByCert with openssl.



I am developing an application where we keep the client certificates in the MS SQL database. We have some tables with secured data. Our application upon request from a client fetches a data and uses the certificate to encrypt the data using the EncryptByCert command of MS SQL. The clients have the private key for the certificate and should be able to decrypt the data. Our clients are unix based and uses openssl. However when the client tries to decrypt the data it cannot.

May I get some help on why the openssl fails to decrypt the data encrypted by MS SQL using the same certificate.


AuthenticateAsClient() exception with OpenSSL server

I have a .NET client and an OpenSSL server doing mutual authentication. SslStream.AuthenticateAsClient() throws the exception "A call to SSPI failed, see inner exception" and the inner exception says "The message received was unexpected or badly formatted". An MSDN article says that this can happen if the server's trusted CA list (which is sent to the client during the SSL handshake) doesn't contain the CA that the client cert is using. I'm setting the trusted CA list in the OpenSSL server so that should be valid. The client and server certs were both signed by the same CA which is valid. If I use a .NET server everything works fine. Is there any way to get specific information about what the client doesn't like? Thanks in advance.

How to replace OpenSSL methods with net ones


Following code in PHP is used to sign data. using private key in pem format. 

    $key = openssl_pkey_get_private ( "pemprivatekey", '' );

openssl_sign ("string to sign", $signature, $key);



How to convert it into C# .NET ? Which net methods shoudl be used instead of openssl ones ?


How to convert PHP openssl signing to .net

PHP Code below signs data using PHP OpenSSL module. How to convert it to C# ?
Which methods should used to replace openssl get key and sign methods ?
  $key = openssl_pkey_get_private (
        file_get_contents ( ''my_private_key.pem'',
 )    );

    if (!openssl_sign ("stringtosign", $signature, $key)) {
        trigger_error ("Unable to generate signature", E_USER_ERROR);

c# deal with openssl (RSA)


Hi there, i'm trying to make an RSA communication between PHP and c# but the generated keys are different between both languages, so:
Is that possible make an RSA communication between c# and php? (i don't want anything about communication, i have it already, i just need to encrypt on PHP and decrypt on c# and vise-versa (using public an private key), nothing else)


Can anyone help me out  : )

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend