sslstream

TCP Client through multithreading in C#

那年仲夏 提交于 2019-12-24 02:12:53
问题 I am connecting to Gmail account using TCP client for reading emails. It returns SslStream for the TCP connection. It works fine for single thread environment but performance is very poor in terms of speed. I need to optimize the project so that its speed can be increased. I have implemented multithreading which increases the speeed but application gets hang at some point. Is it thread safe to use TCP connection (global member)? OR Can I create multiple TCP connections and pass to the thread

Packet fragmentation when sending data via SSLStream

牧云@^-^@ 提交于 2019-12-23 09:55:01
问题 When using an SSLStream to send a 'large' chunk of data (1 meg) to a (already authenticated) client, the packet fragmentation / dissasembly I'm seeing is FAR greater than when using a normal NetworkStream. Using an async read on the client (i.e. BeginRead()), the ReadCallback is repeatedly called with exactly the same size chunk of data up until the final packet (the remainder of the data). With the data I'm sending (it's a zip file), the segments happen to be 16363 bytes long. Note : My

How to allow a Server to accept both SSL and plain text (insecure) connections?

冷暖自知 提交于 2019-12-22 05:45:31
问题 I am trying to create a server that can accept both secure SSL and insecure plain text connection (for backwards compatibility). My code is almost working except the first transmitted data received from an insecure client loses the first 5 bytes (chars) at the server. More specificially if I transmit 30 bytes on an insecure connection, when the server gets to the OnClientDataReceived() function, the line " int iRx = nwStream.EndRead(asyn); ", then iRx = 25 . Any subsequent messages

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

耗尽温柔 提交于 2019-12-21 03:42:12
问题 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

Certificate problem with a new machine - credentials supplied to package not recognized

非 Y 不嫁゛ 提交于 2019-12-19 06:03:05
问题 I am installing a windows service on a new machine. The service does various operations over SslStream over TCP, which uses the certificate in problem. The service has been operating fine with the same code and same certificate on other 2 windows 2003 machines. But, this new machine is Windows 2003 with 64 bit processor too. I am running into this problem when I am trying to run the service with a 'Service Account' identity. It works fine with my own credentials. (Again, it works fine on

Cipher selection for sslStream in .NET 4.5

天涯浪子 提交于 2019-12-18 13:15:43
问题 I am trying to create a TLS1.1/TLS1.2 server using .Net's sslStream class. It appears that by default the only cipher suites that this stream accepts are: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA I'd like to enable non-ECDHE versions of these (i.e. TLS_RSA_WITH_AES_128_CBC_SHA256). I googled around a bit and people talk about changing cipher suites by modifying the default SChannel settings -- either through the "SSL Cipher

Verify Remote Server X509Certificate using CA Certificate File

前提是你 提交于 2019-12-17 20:45:40
问题 I've generated a CA and multiple certificates (signed by CA) using OpenSSL and I have a .NET/C# client and server both using SslStream which each have their own certificates/keys, mutual authentication is enabled and revocation is disabled. I'm using RemoteCertificateValidationCallback for SslStream to validate the remote server's certificate and I was hoping I could just load the CA's public certificate (as a file) in the program and use it to verify the remote certificate rather then

SslStream.AuthenticateAsServer exception - The server mode SSL must use a certificate with the associated private key

为君一笑 提交于 2019-12-13 18:13:03
问题 I am developing a proxy server application similar to CCProxy. Its working fine for HTTP but not HTTPS. Its throwing exception when AuthenticateAsServer() method is called on SslStream object. I also don't know whether I have supplied proper certificate, I don't know how to create a certificate. I just provided the certificate which came with the code that I downloaded online. Here is the code: private static void DoHttpProcessing(TcpClient client) { Stream clientStream = client.GetStream();

SslStream.WriteAsync “The BeginWrite method cannot be called when another write operation is pending”

喜欢而已 提交于 2019-12-12 09:43:33
问题 How to prevent this issue when writing data to the client Asynchronously The BeginWrite method cannot be called when another write operation is pending MYCODE public async void Send(byte[] buffer) { if (buffer == null) return; await SslStream.WriteAsync(buffer, 0, buffer.Length); } 回答1: It is important to understand exactly what the await keyword does: An await expression does not block the thread on which it is executing. Instead, it causes the compiler to sign up the rest of the async

C#: sslStream and local proxy

三世轮回 提交于 2019-12-11 22:15:38
问题 ![enter image description here][1]Hi, We have a server which accepts ssl connection. Say if I request for https://gmail.com then the server first checks if i have logged in to it, if yes then it connects to gmail and sends the response back. If I have not logged in then it redirects to our login page. my requirement is the following: I have to write a TCPListener which listens to the local proxy (say 127.0.0.1:13000). When ever a request comes from browser, I have to create a ssl connection