HttpClientHandler and HTTPS

7 views
Skip to first unread message

Darren Hobbs

unread,
Jan 11, 2015, 11:46:23 AM1/11/15
to utter...@googlegroups.com
Hey folks,

If I want to set a custom SSLContext for HttpClientHandler to use (eg. with a client certificate), what's the best way to do it?

It seems that HttpClientHandler is loaded up in the CoreModule - I'd like to replace it with a different one for certain Modules, as I think I'm going to need to inject some code along the lines of:

if (connection instanceof HttpsURLConnection) {
  connection.setSSLSocketFactory(mySslSocketFactory);
}

Any hints would be appreciated!

Cheers,
-Darren

Daniel Worthington-Bodart

unread,
Jan 11, 2015, 12:52:00 PM1/11/15
to utterlyidle

I would probably just new up a new instance with a new multi method defined on it that works with https connection.

I'll have a look later

--
You received this message because you are subscribed to the Google Groups "utterlyidle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to utterlyidle...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Worthington-Bodart

unread,
Jan 11, 2015, 1:39:40 PM1/11/15
to utterlyidle
This should work:

new ClientHttpHandler() {
@multimethod
    private Response handle(Request request, HttpsURLConnection connection) throws IOException {
         // do some HTTPS stuff
         return handle(request, (HttpConnection) connection); // Carry on as normal
    }
}

You could obviously not make it anonymous and then inject different ones for each context

Daniel Worthington-Bodart

unread,
Jan 11, 2015, 1:58:06 PM1/11/15
to utterlyidle

Yup multi method should do the trick.

Extend ClientHttpHandler add method called handl

Daniel Worthington-Bodart

unread,
Jan 11, 2015, 1:58:40 PM1/11/15
to utterlyidle

Oops duplicate please ignore

Reply all
Reply to author
Forward
0 new messages