简体   繁体   English

如何在Netty上运行的Jersey中获取SSL信息(对等证书)?

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

I'm using the Jersey framework with Netty. 我在Netty中使用Jersey框架。

I am authenticating a client via SSL client-certificate. 我正在通过SSL客户端证书对客户端进行身份验证。

I'm trying to implement a GET whoami() method for clients to call. 我正在尝试为客户端调用一个GET whoami()方法。 I want the response to include some info from the the client ssl certificate used to call the netty server. 我希望响应中包含来自用于调用Netty服务器的客户端SSL证书中的一些信息。

I think I need to use some sort of @Context parameter, but I'm failing to find a way into the SSLEngine. 我认为我需要使用某种@Context参数,但无法找到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. 我找到了一个我想使用Girzzly [1]进行操作的示例,但我未能在netty中找到类似的内容。

Do you have any ideas on how to get access to Client SSL details? 您对如何访问客户端SSL详细信息有任何想法吗? What Context objects are available to me in Netty? Netty对我可用哪些上下文对象?

Update Clarification: How might i get access to the ChannelPipeline from inside my @ GET resource? 更新说明:我如何从@ GET资源内部访问ChannelPipeline?

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

Getting the SSLEngine depends upon how your ChannelPipeline is initialized in Netty. 获取SSLEngine取决于如何在Netty中初始化ChannelPipeline。 One common pattern is to insert a SslHandler into the pipeline like in this example . 一种常见的模式是将SslHandler插入此示例中的管道中。 Here is a unit test where you can explicitly see the SSLEngine being wrapped by a SslHandler and inserted into the pipeline. 这是一个单元测试 ,您可以在其中明确看到SSLEngine被SslHandler包装并插入到管道中。 Once you know how your pipeline is configured you can get elements from the pipeline using ChannelPipeline.get(...) by type or by name. 一旦知道管道的配置方式,就可以使用ChannelPipeline.get(...)按类型或名称从管道中获取元素。

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. 我对您的设置,Netty和Jersey的交互方式以及Netty界面对您的访问方式不熟悉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM