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').
Related
Both this library restup (written by tomkuijsten) and this library SimpleHttpServer implement HTTP server functionality and provide a clean API to embed and use it in UWP projects.
As stated in the first point of the FAQ here and explained here, restup cannot be called by the local machine (I tried even to run a virtual machine, setup a network using a virtual network adapter, but in vain).
But the question is, why is it then possible by SimpleHttpServer!?
Firstly the network socket of the server can be bound to either 0.0.0.0 (All), or explicitly to 127.0.0.1 (localhost), or the IP address of network card eg 192.168.0.2. Secondly HTTP/1.1 requires the host entered into the url to be passed as a header to the server. So either your request isn't sent to the right IP address, the server is rejecting the request based on the Host header, or some other firewall issue is blocking the request.
Restup is using a StreamSocketListener and SimpleHttp is using TcpListener. This would be why the one works locally and the other doesn't.
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
I want to integrate an API that will allow my application to send requests to a web server. Unfortunately, this API is not well documented, and I have not gotten a reply from the person who supports the web service that released the API. The instructions on how to integrate the API are the following:
All API calls connect to the standard SSL port, and must begin with
https://www.websitename.com/api.php?username=username&password=password&,
followed by the list of parameters expressed as parametername=value&
I am new to C# development. Can you interpret this set of instructions and tell me how I'd go about integrating this API? I mainly am confused about connecting to the SSL port.
This sounds like it's just an HTTP request to that particular URL. You want to use the WebClient class, and possibly call the DownloadString method, depending on what the response contains.
The standard SSL port is 443, but if you're using a library that parses URLs correctly, it will connect to that port automatically if it sees https:// at the beginning. You can use a custom port by providing it after the hostname (separated by a :), such as https://websitename.com:8443/, if you had an SSL service running on port 8443 instead of 443.
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
i want to create a proxy server or (Socks host ??) to communicate with browsers (such as firefox) to forward http proxy.
i have a software that do this: bitvise tunnelier.
so, i need to write an application similiar to tunnelier proxy forwarder.
in other words, i want to enable firefox Socks Host and get browser request with c# application
Please help me lead the way
thanks a lot
Create a proxy means that your application need to act as an HTTP Server when talking to the clients (the browsers) and act as a browser when comunicating with the web sites.
The proxy opens a port for the server socket (for example port 90) and accepts the browser request on this port, than connect the web site (generally on port 80) and forward the request to the site server. The proxy waits for the server response, read it and after send the response to the client.
The proxy changes the messages header if needed ( for example change the port in the url).
In general proxy are multi thread applications, so they can manage more request in the same time.