How to get SSL info (peer cert) in Jersey running with Netty?

454 Views Asked by At

I'm using the Jersey framework with Netty.

I am authenticating a client via SSL client-certificate.

I'm trying to implement a GET whoami() method for clients to call. I want the response to include some info from the the client ssl certificate used to call the netty server.

I think I need to use some sort of @Context parameter, but I'm failing to find a way into the SSLEngine.

I found an example of what i want to do using Girzzly[1], but i'm failing to find a similar thing in netty.

Do you have any ideas on how to get access to Client SSL details? What Context objects are available to me in Netty?

Update Clarification: How might i get access to the ChannelPipeline from inside my @ GET resource?

[1]http://jersey.576304.n2.nabble.com/Context-SecurityContext-not-initialized-with-SSL-client-certs-td7556681.html

1

There are 1 best solutions below

2
On BEST ANSWER

Getting the SSLEngine depends upon how your ChannelPipeline is initialized in Netty. One common pattern is to insert a SslHandler into the pipeline like in this example. Here is a unit test where you can explicitly see the SSLEngine being wrapped by a SslHandler and inserted into the pipeline. Once you know how your pipeline is configured you can get elements from the pipeline using ChannelPipeline.get(...) by type or by name.

For a more specific answer you will have to provide more details about your configuration. I'm not familiar with your setup, how Netty and Jersey are interacting, or how accessible Netty's interfaces are to you.