I'm trying to build an application that would use TCP sockets to communicate with a server.
When a proxy is detected in system settings, the application tries to connect through it through these steps:
Connect to proxy.
Issue CONNECT Host:Port HTTP/1.1<CR><LF>
Issue <CR><LF>
However it turns out that the proxy also needs to do NTLM authentication using the credentials of current user who's logged in.
.Net already implement this using:
Webproxy.crendentials = CredentialCache.GetDefaultCrendentials
But it only works with WebRequests types of sockets. And I am using regular sockets with Stream.Read and Stream.Write
Related
I'm attempting to get client and server applications (developed in C# and .NET) using secure web sockets to validate the certificates within the applications.
Is there a mechanism for a WebSocket (System.Net.Websockets.WebSocket in .NET) using a secure (wss) connection to perform custom validation on a client certificate? And similarly a client WebSocket to perform custom validation of the server certificate?
For example, with the .NET class SSLStream a RemoteCertificateValidationCallback can be passed to the constructor. I assume there is a similar mechanism for WebSockets but I can't seem to find any examples or documentation.
I had the same issue with the websocket client implementation and could not find any way to do that using System.Net.Websockets.WebSocket.
I solved it using a System.Net.Sockets.Socket to establish the connection and then implement the client-server handshake to upgrade the Socket connection to a websocket connection with the websocket server, and also implemented other methods to send messages and to continuously read for incoming data, simulating the WebSocket behavior (you can find how to do that in several code examples and open source websocket libraries, i.e. https://github.com/kerryjiang/WebSocket4Net ).
I have a local c# server running and listening on localhost and a browser connecting to a cloud service running a JavaScript HTML5 implementation of websockets. Standard ws://
This works great over HTTP:// and I can read the header and use it, but I need it to run in HTTPS:// I understand that I have to change to wss:// and this does connect to my server but the header is garbled/encrypted.
I have looked into SslStream but drawn a blank.
How do I handle this WebSocket Secure header in C#?
This question was answered in the comments:
If your app is behind a Proxy load balancer, it would normally manage the SSL for you (accessing your app without encryption).
If you need to manage SSL, complete the SSL handshake first (usually right after you accept the connection) and than parse protocol specific data (HTTP, Websockets, SMTP etc').
I have several clients connected to a server using TCP. Because of some problems with the TCP (or the IT policies) I want to change the protocol to TCP using either web service or web API
The problem is that the HTTP is a request from client to server, but not the other way around
I want to create this option where the server can push responses to the client
Server:
.NET windows application with TCP connections, hold few clients each client has a logic instance
Client:
.net windows application with TCP connection
Because of the server architecture I don't want to use ASP.NET or other application rely on IIS.
Does WCF can provide me with this solution?
We use SignalR in one of our projects
NuGet package
Video Tutorial
IIS is not necessary, you can self-host this service (as we just do)
I had Implemented TCP Client With SSlstream and try to connect server. I had provided Client certificate. Now the Problem is that when i tried to run the client when server Certificate is required and ClientAuthentication Required in that case it works succesfully.
But when i tried to connect with server settings Client Authentication not required at that time i am not able to do the proper communication and it is giving me that connection to port is not successful because underlying connection is closed. so please suggest what is exact tcpclient sslstream implementation which will connect with SSL Enabled server and Client Authentication is not required.
it seems like when there is clientAuthentication is not required at that time it gives it is still checking for authentication so it is giving me IsMutuallyAuthenticated Property of sslStream class false where is IsAuthenticatedProperty true.
The issue was with the server implementation , due to configuring it with the not required client certificate, it was internally taking that into consideration, once i tried with fresh implementation of server i was able to connect when there is no client authentication required implementation as well.
I am using the HTTP Proxy setting on my ipad to redirect traffic to my .net httplistener.
If i send http traffic using the ipad proxy sends the traffic to my httplistener, and
my code does its thing. If i send https traffic using the ipad and its http proxy I see the packets show up at my machine (sniff using wireshark) on port 8443, but my listener doesn't get kicked off. I have the prefixes and certificates correct. I proved this out by instructing a browser to go directly to my machine w/o the http proxy using port 8443.
I noticed from my sniffs of the https connection attempt that the HTTP CONNECT method
is contained in the packet. Its probably trying to tunnel the SSL traffic. Does http.sys or httpListener recognize/handle the CONNECT method ? I am curious why my httplistener isn't firing off ??
thoughts on how I can further troubleshoot this ?
It's not stated in your question, so have you actually setup your HttpListener to support SSL with a site certificate as documented in this question?
How do I add SSL to a .net application that uses httplistener - it will *not* be running on IIS