sslstream

C# SSL secure sockets

旧街凉风 提交于 2019-12-06 06:24:34
问题 I have a fine, working communicator application, written in C#. Now I need to implement a secure connection to the server. I've tried changing Socket and TcpClient objects into SslStream, but I got a few errors. Firstly I generated a .cer certificate using makecert. OpenSSL certificates didn't worked for me, because they didn't include private key. Next I created a certificate object on the server and bound it to the SslStream: X509Certificate serverCertificate = X509Certificate

How to validate self-signed certification

南楼画角 提交于 2019-12-06 03:49:11
i will provide you with my question clearly so you can answer me I have a client-server (socket) connection that i secured using SslStream and as i know using ssl makes me sure that my client will only connect to my server And to do that i must add a function to my client to validate the server certification and make sure that the server is the real one (my server) but i really don't get how could i validate my self-signed certification and want your help Regards, and my thanks in advance Imagine if the certificate were not self signed - it is signed by a trusted certificate authority. The

Mutual SSL Authentication - Local certificate in sslstream returning 'null' instead of certificate on client

◇◆丶佛笑我妖孽 提交于 2019-12-05 07:09:08
I am working on creating an windows service which will make a call to a API. For this process, I am trying to establish a Mutual (Two way) SSL authentication. Since I am newbie to this. I tried to implement a simple client and server project which will authenticate mutually. I have created the self signed certificate exchanged and added in trusted certificates. My Client using System; using System.Configuration; using System.Net.Security; using System.Net.Sockets; using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; using System.Text; namespace

C# SSL secure sockets

会有一股神秘感。 提交于 2019-12-04 12:09:43
I have a fine, working communicator application, written in C#. Now I need to implement a secure connection to the server. I've tried changing Socket and TcpClient objects into SslStream, but I got a few errors. Firstly I generated a .cer certificate using makecert. OpenSSL certificates didn't worked for me, because they didn't include private key. Next I created a certificate object on the server and bound it to the SslStream: X509Certificate serverCertificate = X509Certificate.CreateFromCertFile("ca.cer"); TcpClient clientSocket = this.tcpListener.AcceptTcpClient(); SslStream ssls = new

Sending files over TCP/ .NET SSLStream is slow/not working

浪子不回头ぞ 提交于 2019-12-04 01:48:47
问题 Im writing an Server/Client Application which works with SSL(over SSLStream ), which has to do many things(not only file receiving/sending). Currently, It works so: Theres only one connection. I always send the data from the client/server using SSLStream.WriteLine() and receive it using SSLStream.ReadLine() , because I can send all informations over one connection and I can send from all threads without destroying the data. Now I wanted to implement the file sending and receiving. Like other

How to (repeatedly) read from .NET SslStream with a timeout?

混江龙づ霸主 提交于 2019-12-03 10:20:14
I just need to read up to N bytes from a SslStream but if no byte has been received before a timeout, cancel, while leaving the stream in a valid state in order to try again later. (*) This can be done easily for non-SSL streams i.e. NetworkStream simply by using its ReadTimeout property which will make the stream throw an exception on timeout. Unfortunately this approach doesn't work on SslStream per the official docs: SslStream assumes that a timeout along with any other IOException when one is thrown from the inner stream will be treated as fatal by its caller. Reusing a SslStream instance

How do I identify my server name for server authentication by client in c#

末鹿安然 提交于 2019-12-03 00:15:11
I have recently been trying to make a SSL encrypted Server/Client in C#. I have followed this tutorial on MSDN, however, it required a certificate to be created for the server and client usage using makecert.exe so I found an example and it created the certificate fine: makecert -sr LocalMachine -ss My -n "CN=Test" -sky exchange -sk 123456 c:/Test.cer but now the problem is the server starts and waits for clients, when the client connects it uses the machine name which as far as I can gather is my IP in this case: 127.0.0.1 , and then it requires the servers name which must match the servers

Using SslStream with IOCP

走远了吗. 提交于 2019-12-02 09:36:19
问题 I have written a TCP server using the Socket class's asynchronous/IOCP methods, BeginSend()/BeginRead()/etc. I would like to add SSL capability using SslStream, but from the interface it looks like Socket and SslStream are not intended to work together, in particular because I'm not using Streams at all and SslStream appears to depend on having a Stream to work with. Is this possible, or am I looking in the wrong place? Do I need to fashion my own Stream subclass that feeds into my Socket

Using SslStream with IOCP

跟風遠走 提交于 2019-12-02 06:59:33
I have written a TCP server using the Socket class's asynchronous/IOCP methods, BeginSend()/BeginRead()/etc. I would like to add SSL capability using SslStream, but from the interface it looks like Socket and SslStream are not intended to work together, in particular because I'm not using Streams at all and SslStream appears to depend on having a Stream to work with. Is this possible, or am I looking in the wrong place? Do I need to fashion my own Stream subclass that feeds into my Socket instances and point SslStream at that? It's important to me that my server use IOCP due to scaling

Sending files over TCP/ .NET SSLStream is slow/not working

自作多情 提交于 2019-12-01 10:57:29
Im writing an Server/Client Application which works with SSL(over SSLStream ), which has to do many things(not only file receiving/sending). Currently, It works so: Theres only one connection. I always send the data from the client/server using SSLStream.WriteLine() and receive it using SSLStream.ReadLine() , because I can send all informations over one connection and I can send from all threads without destroying the data. Now I wanted to implement the file sending and receiving. Like other things in my client/server apps, every message has a prefix (like cl_files or sth) and a base64 encoded