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
2
votes
2 answers

Why does SslStream.Read always set TcpClient.Available to 0, when NetworkStream.Read doesn't

I have a TcpClient client connected to a server, that send a message back to the client. When reading this data using the NetworkStream.Read class I can specify the amount of bytes I want to read using the count parameter, which will decrease the…
Remy
  • 4,843
  • 5
  • 30
  • 60
2
votes
0 answers

SslStream.AuthenticateAsClient for two streams against same Socket fails

I've had a design where one Socket has two NetworkStream opened: one for reads and one for writes. When updating the code to start using SslStreams a call to sslStream.AuthenticateAsClientAsync yields an error for the second stream (order is not…
Daniel
  • 8,133
  • 5
  • 36
  • 51
2
votes
1 answer

How to make an HTTP Get request along with SslStream & TcpClient

In my application I am using the below code to validate the client certificate public static async Task CallApi(string url, Context context) { var hostName = "mytestapp.azurewebsites.net"; var port = 443; Stream keyin =…
Sooraj
  • 133
  • 1
  • 7
2
votes
1 answer

How do I send Push Notification with "apns-expiration" header using standard C#.NET?

You can find similar code examples in many places on the internet: var apnsHost = "gateway.sandbox.push.apple.com"; var apnsPort = 2195; var timeout = 3000; using(TcpClient client = new TcpClient(AddressFamily.InterNetwork)) { await…
Mikser
  • 929
  • 10
  • 16
2
votes
2 answers

Asking SslStream to accept ONLY a certificate signed by a particular public key

I have a working implementation of this but want to make sure it is secure. The goal is to use SSLStream and only accept SSL certificates from the server that are signed by a particular RSA key. Here is my connection code: var client = new…
adam smith
  • 764
  • 7
  • 16
2
votes
0 answers

TcpClient/SslStream - An established connection was aborted by the software in your host machine

I have an SSL-connection managed with TcpClient/SslStream. Every 10 seconds I send a heartbeat-type request to keep it fresh: try { this.sslStream.Write(byteArray, 0, byteArray.Length); } …
Pingguoren
  • 31
  • 4
2
votes
1 answer

Connecting to .NET Sslstream x.509 socket with Python or Ruby or Perl

I have a weird requirement. I am trying to communicate with a server written in C#. It looks like this basically: SslStream sslStream = new SslStream(client.GetStream(), true, ValidateServerCertificate, …
Chris
  • 51
  • 5
2
votes
1 answer

Difference between AuthenticateAsClient and AuthenticateAsServer

What is the difference between SslStream.AuthenticateAsClient and SslStream.AuthenticateAsServer methods? When should I use what? I checked many examples. But I can't understand what should be used by client and what should be used by server.
Lasitha Yapa
  • 4,309
  • 8
  • 38
  • 57
2
votes
0 answers

SslStream throwing ArgumentNullException with .Net 4.6

The following piece of code (copy/paste ready, just replace the IP/port by something valid) throw an ArgumentNullException (nothing helpful in the stacktrace) on the line sslStream.AuthenticateAsClient: namespace Test { using System; using…
ken2k
  • 48,145
  • 10
  • 116
  • 176
2
votes
1 answer

UDP with SSL Stream

Hi I'm working on server/Client project with C# that uses both TCP (for logging in and other stuff) and UDP (for streaming voice ). The problem is that I need to use sslStream for UDP but as far as I know its not possible to make SSL authentication…
Farid Fereidooni
  • 131
  • 1
  • 12
2
votes
2 answers

SSLStream reads invalid data + KB3147458 SSLStream bug (?)

I'm having an issue with SSLStream returning some data when the remote client did not send anything. I am having this issue when the server is listening for a new command. If the server doesn't receive a new request, the ReadMessage() function…
A. Colomba
  • 53
  • 6
2
votes
1 answer

"Call to SSPI failed" when connecting to OpenSSL Server

When calling AuthenticateAsClient(), I receive the error "Call to SSPI failed." with the inner exception "The message received was unexpected or badly formatted". I've seen this to be a semi-popular problem, but I haven't been able to find a working…
Sinaesthetic
  • 11,426
  • 28
  • 107
  • 176
2
votes
1 answer

Read SslStream continuously in C# Web MVC 5 project

tl;dr: "I would like to read an SslStream continuously in C# but I can't figure out the best way." Some background: I'm getting stock data from a stream that I would like to present in a web interface. The stream sends a heartbeat every 5 seconds…
Ogglas
  • 62,132
  • 37
  • 328
  • 418
2
votes
1 answer

Authentication failed because the remote party has closed the transport stream

I am maintaining our Nominet domains through their EPP System. To do this is I am instantiating a TCP client and connecting using an ssl stream, everything is working fine locally in my virtual machine using both IIS and IIS Express. However, when…
Ant
  • 338
  • 2
  • 9
2
votes
1 answer

Listen for additional requests on the same stream (TCPClient/SSLStream)?

So I have a client server model based off of using a TCPClient's stream and turning it into an SSLStream for security purposes, but each time the client wants to send something new to the server, it opens a new TCP connection to the server as the…