poco
poco copied to clipboard
HTTPS proxy support
Hello everyone.
I use Poco HTTP client to work with HTTPS endpoint through an HTTPS proxy but I'm getting timeout errors in such configuration. Looking at HTTP(S)ClientSession source code I see that proxyConnect()
method establishes a non-secure HTTP connection with a proxy and proxyRequestPrefix()
returns only "http" proxy prefix:
std::string HTTPClientSession::proxyRequestPrefix() const
{
std::string result("http://");
...
StreamSocket HTTPClientSession::proxyConnect()
{
ProxyConfig emptyProxyConfig;
HTTPClientSession proxySession(getProxyHost(), getProxyPort(), emptyProxyConfig);
...
As I can understand Poco doesn't support HTTPS proxy. Is there any way to modify source code to get HTTPS proxy support in the case when both endpoint and proxy work with the same certificates?
It should be possible by changing the HTTPClientSession::proxyConnect()
method to use Poco::Net::HTTPSessionFactory
to create the Poco::Net::HTTPClientSession
or Poco::Net::HTTPSClientSession
object instead of a hard-coded Poco::Net::HTTPClientSession
.
An additional protocol
member should be added to ProxyConfig
, denoting the protocol to use (http
or https
). The protocol value can then be given to Poco::Net::HTTPSessionFactory::createClientSession()
to obtain the session for the proxy request. You'll also need to manage a separate HTTPSessionFactory
for use by HTTPClientSession
, as the default one may itself have proxy parameters configured.
@obiltschnig Thank you very much for your feedback. I'll try to fix it in a fork and after success will commit to upstream.
What's likely not going to work with this approach is sending HTTP requests through a HTTPS proxy. But that's kind of pointless anyway.
@obiltschnig I've done. Could you please review the change about HTTPS proxy? https://github.com/pocoproject/poco/pull/3040
This issue is stale because it has been open for 365 days with no activity.
This issue was closed because it has been inactive for 60 days since being marked as stale.
This issue is stale because it has been open for 365 days with no activity.
#3691