You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Gary Gregory <ga...@gmail.com> on 2017/05/05 22:46:11 UTC

Is a NHttpServerConnection encrypted?

Hi all,

I have implemented a
com.rs.seagull.httpmonitor.NHttpReverseProxy.ProxyServiceHandler.connected(
NHttpServerConnection)

and I want to log whether this is a plain or SSL connection.

NHttpServerConnection's toString() tells me something like "127.0.0.1:1102
<->127.0.0.1:65096" which is nice but does not tell me if the connection is
encrypted. I'd like to find out in that method when I do the logging.

Aside from hacking and introspecting into objects to find an SSLIOSession
and toString()'ing that.

Can anyone think of clean way to either get this information or modify
something?

Gary

-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<https://www.amazon.com/gp/product/1617290459/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1617290459>
JUnit in Action, Second Edition
<https://www.amazon.com/gp/product/1935182021/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182021>
Spring Batch in Action
<https://www.amazon.com/gp/product/1935182951/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182951>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: Is a NHttpServerConnection encrypted?

Posted by Gary Gregory <ga...@gmail.com>.
On Sat, May 6, 2017 at 1:43 AM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Fri, 2017-05-05 at 15:46 -0700, Gary Gregory wrote:
> > Hi all,
> >
> > I have implemented a
> > com.rs.seagull.httpmonitor.NHttpReverseProxy.ProxyServiceHandler.conn
> > ected(
> > NHttpServerConnection)
> >
> > and I want to log whether this is a plain or SSL connection.
> >
> > NHttpServerConnection's toString() tells me something like
> > "127.0.0.1:1102
> > <->127.0.0.1:65096" which is nice but does not tell me if the
> > connection is
> > encrypted. I'd like to find out in that method when I do the logging.
> >
> > Aside from hacking and introspecting into objects to find an
> > SSLIOSession
> > and toString()'ing that.
> >
> > Can anyone think of clean way to either get this information or
> > modify
> > something?
> >
> > Gary
> >
>
> Try getting "http.session.ssl" attribute from the connection context.
>
> ---
> NHttpConnection conn = ...
> SSLIOSession sslioSession = (SSLIOSession) conn.getContext().
> getAttribute(SSLIOSession.SESSION_KEY);
> SSLSession sslSession = sslioSession != null ?
> sslioSession.getSSLSession() : null;
> ---
>

Works like a champ. Thank you Oleg.

Gary


>
> Oleg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<https://www.amazon.com/gp/product/1617290459/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1617290459>
JUnit in Action, Second Edition
<https://www.amazon.com/gp/product/1935182021/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182021>
Spring Batch in Action
<https://www.amazon.com/gp/product/1935182951/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182951>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: Is a NHttpServerConnection encrypted?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2017-05-05 at 15:46 -0700, Gary Gregory wrote:
> Hi all,
> 
> I have implemented a
> com.rs.seagull.httpmonitor.NHttpReverseProxy.ProxyServiceHandler.conn
> ected(
> NHttpServerConnection)
> 
> and I want to log whether this is a plain or SSL connection.
> 
> NHttpServerConnection's toString() tells me something like
> "127.0.0.1:1102
> <->127.0.0.1:65096" which is nice but does not tell me if the
> connection is
> encrypted. I'd like to find out in that method when I do the logging.
> 
> Aside from hacking and introspecting into objects to find an
> SSLIOSession
> and toString()'ing that.
> 
> Can anyone think of clean way to either get this information or
> modify
> something?
> 
> Gary
> 

Try getting "http.session.ssl" attribute from the connection context.

---
NHttpConnection conn = ...
SSLIOSession sslioSession = (SSLIOSession) conn.getContext().getAttribute(SSLIOSession.SESSION_KEY);
SSLSession sslSession = sslioSession != null ? sslioSession.getSSLSession() : null;
---

Oleg

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org