On Wed, Oct 31, 2012 at 09:35:56AM -0700, John Sheehy wrote:
> Actually one more question if you will - what I'm actually trying to do is
> to get a callback/event when the underlying connection assigned to a
> HttpGet or HttpPost request has finished its SSL handshaking - i.e. when
> it's ready to write encrypted bytes to the wire, both in the case where it
> needs to negotiate it, and also when it reuses already secured connection.
> 
> Just in case, is there something specific that does this? if not, I assume
> I can eventually get there by somehow getting the SSL socket out of the
> request and keeping a mapping to some callback or other.
> 
> Thx.
> 


HttpClient intentionally does not provide an easy way of getting access to the 
underlying sockets in order to ensure sockets are not modified in some way that 
would render them non-reusable without the framework detecting that. One can 
still add a custom request interceptor in order to get access to the HTTP 
connection obtained from the connection manager to execute the request and get 
hold of the network socket by calling 

http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/conn/DefaultClientConnection.html#getSocket%28%29

Hope this helps

Oleg



> On Wed, Oct 31, 2012 at 9:32 AM, John Sheehy <[email protected]> wrote:
> 
> > That's great! Thanks a lot to both of you.
> >
> >
> > On Wed, Oct 31, 2012 at 8:58 AM, Luca Colantonio <[email protected]>wrote:
> >
> >> hi,
> >>
> >> if you'd like to see an example on how to do it you could have a look at
> >> how the browsermob project does it in order to collect metrics:
> >>
> >> the custom ssl socket factory
> >>
> >> https://github.com/webmetrics/browsermob-proxy/blob/master/src/main/java/org/browsermob/proxy/http/TrustingSSLSocketFactory.java
> >>
> >> the custom ssl socket that sets the listener Oleg mentioned:
> >>
> >> https://github.com/webmetrics/browsermob-proxy/blob/master/src/main/java/org/browsermob/proxy/http/SimulatedSSLSocket.java#L26
> >>
> >> hope that helps
> >>
> >> --luca
> >>
> >> On Wed, Oct 31, 2012 at 12:58 PM, Oleg Kalnichevski <[email protected]
> >> >wrote:
> >>
> >> > On Tue, Oct 30, 2012 at 02:42:47PM -0700, John Sheehy wrote:
> >> > > Hi all,
> >> > >
> >> > > using HttpComponents client 4.2.2, is there a way I can be notified
> >> when
> >> > an
> >> > > SSL connection is ready for writing? I'm using a
> >> > > PoolingClientConnectionManager and I think I need to somehow override
> >> > > DefaultClientConnection's update() method which should be called when
> >> the
> >> > > TLS negotiation is complete, but I'm not sure how the plumbing works.
> >> > >
> >> > > Any help appreciated,
> >> > > John.
> >> >
> >> > John
> >> >
> >> > JSSE API exposes a simple and effective mechanism of getting SSL
> >> protocol
> >> > level notifications by registering a listener on an SSL socket instance
> >> >
> >> >
> >> >
> >> http://docs.oracle.com/javase/6/docs/api/javax/net/ssl/SSLSocket.html#addHandshakeCompletedListener%28javax.net.ssl.HandshakeCompletedListener%29
> >> >
> >> > All it probably takes on the HttpClient side is a custom socket factory
> >> or
> >> > a hostname verifier.
> >> >
> >> > Oleg
> >> >
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: [email protected]
> >> > For additional commands, e-mail: [email protected]
> >> >
> >> >
> >>
> >
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to