Questions tagged [sslstream]

.NET class that provides a stream used for client-server communication that uses TLS/SSL security protocols to authenticate the server and optionally the client.

Documentation: https://msdn.microsoft.com/en-us/library/system.net.security.sslstream.aspx

231 questions
3
votes
1 answer

SslStream EndRead gets first 1 Byte

I've written a TcpClient and Server which are communicating via an SslStream. The communication works, but when i send a message from the Client to the Server, first the Server reads 1 Byte, and in the next step the rest. Example: I want to send…
DirtyNative
  • 2,553
  • 2
  • 33
  • 58
3
votes
0 answers

How correct use lock with Socket, NewtorkStream and SslStream?

I've got a server that uses a Socket with SslStream like this: Socket senderSocket; NetworkStream nStream = new NetworkStream(senderSocket, true); SslStream ssStream = new SslStream(nStream); I use the SslStream's synchronous Write and async…
user1711993
  • 271
  • 4
  • 20
3
votes
4 answers

Makecert certificates safe?

I made an application, which communicates over the. net SSLStream, and for developing I used makecert.exe to create a self signed ssl certificate. Now Ive read in some microsoft article, that makecert should be used for testing only. Now my…
Tearsdontfalls
  • 767
  • 2
  • 13
  • 32
3
votes
2 answers

SSLStream: "A Call to SSPI Failed" Exception

I have a strange problem: I wrote a server and client in c# based on .net2 which are chatting over the .net 2 SslStream. There is 1 Connection for sending commands between Cl and S and theres one connection for sending files between cl and…
Tearsdontfalls
  • 767
  • 2
  • 13
  • 32
3
votes
0 answers

Asynchronous SSL Socket

Recently I was creating an asynchronous ssl socket class. I finished it, and it authenticated with the client successfully but it did not receive the message sent by client correctly. Here is my code: using System; using…
Roman Ratskey
  • 5,101
  • 8
  • 44
  • 67
3
votes
3 answers

Weird behaviour of SslStream.Read()

Working on some socket layers using SslStream. reference Using the reference, I implemented a simple client. The awkward part is when you run the application, it seems the server is not replying to the client. Going into the debug screen and setting…
Derpy Derp
  • 429
  • 1
  • 5
  • 12
3
votes
3 answers

Construct GET Request for SslStream

I apologise if this is a bit dim but I want to send something like this over an sslstream to a server that I have acquired a secure socket connection to... GET /F5Check/qpi/1 HTTP/1.1 Host: *****.com Connection: keep-alive Cache-Control:…
Dave Lawrence
  • 3,843
  • 2
  • 21
  • 35
2
votes
3 answers

How to make NUnit test wait for thread to complete?

I have following problem with testing class library with NUnit When i call this method from console app or other project it works propertly - App will work as long as listenerThread is running. public void StartServer(string ListenOnIp, int port,…
vvvanderer
  • 21
  • 3
2
votes
2 answers

C# TcpListener and MySqlConnection stops accepting connections after a while

I have an async socket server written in C#, running on a Lightsail server running Amazon Linux. It consists of a TcpListener that accepts connections, starts up a new thread to listen when someone connects, initiates an SSL connection, and then…
OrdiNeu
  • 23
  • 1
  • 6
2
votes
1 answer

Why is calling SslStream.AuthenticateAsServer and SslStream.AuthenticateAsClient with the same certificate in the same process not supported?

I recently ran into an issue when converting socket communication to use System.Net.Security.SslStream instead of NetworkStream. This conversion was targeting a solution of .Net Framework 4.8 projects. The requirements of this task dictated mutual…
smarcaurele
  • 425
  • 3
  • 9
2
votes
1 answer

Powershell failing during call to AuthenticateAsClient when only TLS 1.2 available on server

I am trying to create a secure socket with Powershell, but it fails during the call to AuthenticateAsClient with a variety of errors like Unable to read data from the transport connection: An existing connection was forcibly closed by the remote…
Code39
  • 166
  • 9
2
votes
1 answer

How to moq a SslStream in unit test?

I would like to mock AuthenticateAsClientAsync method in the SslStream class. I also want to mock the different security cases used by the SslStream for example: IsAuthenticated, IsEncrypted and IsSigned. Mocking seems possible, because the method…
Péter Szilvási
  • 362
  • 4
  • 17
2
votes
1 answer

SslStream read does not return client's message

I am trying to implement a client-server application using TLS (openssl). I followed the example given in rust doc for my code's structure: example Server Code fn handle_client(mut stream: SslStream){ println!("Passed in handling…
vxek
  • 123
  • 3
2
votes
2 answers

Problem with HTTPs request and SslStream on some sites

I have a simple C# app that makes a HTTPs request using TcpClient and SslStream. Everything works fine, except some websites that use TLS 1.3 are failing. I upgraded project to .Net Framework 4.8, also read slowly…
Zeokat
  • 504
  • 1
  • 5
  • 16
2
votes
2 answers

sslStream.Read problem: all bytes read are 0

TcpClient client = new TcpClient("69.147.112.160", 443); SslStream sslStream = new SslStream(client.GetStream(),false, ValidateServerCertificate,null); try { …
Roozbeh Sharafi
  • 347
  • 1
  • 6
  • 21