Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] HTTPS and ProxyServlet

Hi,
Do I have to describe more details on my point?

I followed the solution at http://stackoverflow.com/questions/9852056/jetty-proxyservlet-with-ssl-support
1. Create a class which extends from AsyncProxyServlet class.
2. Override createHttpClient() method. The key here is that the HttpClient instance which you will create will need an SslContextFactory(). Just set SslContextFactory with appropriate settings on HttpClient object and you will be good to go.

But it doesn't work.

Does Jetty proxy support this scenario?

Thanks!

On Fri, Apr 8, 2016 at 4:37 PM, Mark Wang <mark.wu.wang@xxxxxxxxx> wrote:
Hi,
I'm using Jetty 9.3.5, and take advantage of ProxyServlet as a tunnel proxy.
Please consider the following test codes,

********************************
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setSslContext(sslContext);

HttpClient client = new HttpClient(sslContextFactory);
client.getProxyConfiguration().getProxies().add(new HttpProxy(new Origin.Address(host, port), true));
client.start();

String url = "">ContentResponse response = client.newRequest(url).send();
System.out.println(response.getContentAsString());
client.stop();
********************************

If the url is HTTP path, it works well.But if the url is HTTPS path, say, https://host:sslPort/xxx, it reports 404 error.
The exception shows some message, like
org.eclipse.jetty.client.HttpResponseException: Received HttpResponse[HTTP/1.1 404 Not Found]@1aed4133 for HttpRequest[CONNECT host:sslPort HTTP/1.1]@5b1d67b3

I have set SSL context for the client. What is missing?

Thanks!


Back to the top