Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPS traffic over a proxy is sent unencrypted #319

Open
ristowee opened this issue Mar 6, 2023 · 0 comments
Open

HTTPS traffic over a proxy is sent unencrypted #319

ristowee opened this issue Mar 6, 2023 · 0 comments

Comments

@ristowee
Copy link

ristowee commented Mar 6, 2023

Hi,
There's a problem when trying to transfer https traffic over an http proxy. The current implementation does not send the CONNECT message to the proxy that would establish a tunnel for the end-to-end https connection. Instead the data is initiated with a GET message and the rest of the data is sent unencrypted between the client and the proxy.

There's already a pull request that would fix this issue by using an agent, which would take care of the proxy connection (#143). I decided to create an issue in case the pull request was accidentally overlooked.

Of course, if the server used http then the agent should be HttpProxyAgent instead. Alternatively, the old proxy functionality could be kept for the http server but the documentation should point out that the that it shouldn't be used for the https traffic.

diff --git a/lib/eventsource.js b/lib/eventsource.js
index 69c5525..76e9621 100644
--- a/lib/eventsource.js
+++ b/lib/eventsource.js
@@ -112,7 +112,10 @@ function EventSource (url, eventSourceInitDict) {
     // If specify http proxy, make the request to sent to the proxy server,
     // and include the original url in path and Host headers
     var useProxy = eventSourceInitDict && eventSourceInitDict.proxy
-    if (useProxy) {
+    var agent = eventSourceInitDict && eventSourceInitDict.agent
+    if (agent) {
+      options.agent = agent
+    } else if (useProxy) {
       var proxy = parse(eventSourceInitDict.proxy)
       isSecure = proxy.protocol === 'https:'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant