-
Notifications
You must be signed in to change notification settings - Fork 14
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
Support using https
requests with an http
proxy
#28
Conversation
Signed-off-by: David Festal <[email protected]>
Signed-off-by: David Festal <[email protected]>
Conflicts: src/index.ts
https
requests with an http
proxy
So in order to have the PR ready to merge we still need to:
|
@vinokurig Do you plan to work on those remaining tasks ? cc @ericwill |
I'll handle this PR |
45c81d8
to
0006084
Compare
https
requests with an http
proxyhttps
requests with an http
proxy
@sleshchenko @olexii4 @akurinnoy The PR is ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/index.ts
Outdated
}); | ||
return axios.create({httpsAgent: agent}); | ||
if (!this.isItNode()) { | ||
this.addLogInterceptorsIfEnabled(axios); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this makes sense to add interceptor in the browser case, since the process
object will not be available ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the reading of the env variable instead I added a new property to config, so the logging can be controlled by the API
61aa8ca
to
5921960
Compare
5921960
to
68aaf8b
Compare
So last tests results:
So it seems now we lost the access to the the API server with proxies when TLS in not enabled Additionally, changing the configuration of the request/response logging to push to the
|
src/index.ts
Outdated
}); | ||
} | ||
} else { | ||
axiosRequestConfig.httpAgent = proxyIsHttps ? httpsOverHttpsAgent : httpOverHttpsAgent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaict here it should be:
axiosRequestConfig.httpAgent = proxyIsHttps ? httpOverHttpsAgent : httpOverHttpAgent,
Of course you would have to define them just above.
TBH I'd rather define all the const just above as you did for httpOverHttpsAgent
. To me it would make the logic much clearer and voir this type of errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/index.ts
Outdated
proxy: mainProxyOptions, | ||
ca: certificateAuthority ? [certificateAuthority] : undefined | ||
}); | ||
const httpsOverHttpsAgent = tunnel.httpsOverHttps(httpsProxyOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fear that here you will have to also add the ca
at the top level, besides the proxy
argument.
(that's a case we cannot test for now, but that's how tunnel docs shows in the examples).
ca
at the top-level, when target URL is https
ca
in the proxy settings, when the proxy itself is https
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
The goal of this PR is to fix issue eclipse-che/che#16356
The error was coming from the fact that
axios
implementation ofhttps
requests through ahttp
proxy is limited. In particular, it seems it doesn't correctly use the CONNECT method that allows tunneling ahttps
request inside ahttp
proxy.A consequence of this is that the underlying socket connection opened to finally reach the target endpoint is not a ssl socket. This finally results in an error from the Proxy, especially with self-signed certificates.
The fix configures
axios
to override eitherhttp
orhttps
agent (according to whether TLS is used) with agents created by thetunnel
module.This PR was tested on a disconnected environment with an HTTP proxy, and TLS enabled with self-signed certificates.