简体   繁体   English

Java对服务器角色中的服务器名称指示(SNI)的支持?

[英]Java support for Server Name Indication (SNI) in server role?

Java 7 brings client support for SNI . Java 7带来了对SNI的客户端支持 Are there known open-source implementations of the SNI server role? 是否存在SNI服务器角色的已知开源实现? Java provides "transparant support" TLS connections (including the handshake), but I need to decouple the handshake process so I can send a certificate back based on the SNI host_name extension. Java提供了“透明支持” TLS连接(包括握手),但是我需要解耦握手过程,以便可以基于SNI host_name扩展名发回证书。

After failing to find online documentation, I looked in the OpenJDK source code, but there does not seem to be a point where I can monitor the ClientHello message before Java sends the ServerHello message. 在找不到在线文档之后,我查看了OpenJDK源代码,但是似乎没有什么地方可以在Java发送ServerHello消息之前监视ClientHello消息。

I made a quick hack some time ago: https://bitbucket.org/zmarcos/sniserversocket 我前段时间做了一个快速hack: https : //bitbucket.org/zmarcos/sniserversocket

If you follow the instructions: https://bitbucket.org/zmarcos/sniserversocket/wiki/Home 如果您按照说明进行操作: https : //bitbucket.org/zmarcos/sniserversocket/wiki/Home

It will work even on Java EE servers, like Glassfish. 它甚至可以在Java EE服务器(例如Glassfish)上运行。

I don't know of a known open-source implementation for for Java 7, but server SNI support is coming in Java 8 . 我不知道Java 7的已知开源实现,但是Java 8中将提供对服务器SNI的支持。 If you back-port this to Java 7, I'd love to know. 如果您将此移植回Java 7,我很想知道。

I came across the same problem myself and ended up writing an open source library: TLS Channel . 我本人也遇到了同样的问题,最后写了一个开源库TLS Channel The scope of the library is actually bigger: it is a complete abstraction for SSLEngine (which is seriously hard to use directly), exposing it as a ByteChannel. 该库的范围其实更大:它是SSLEngine的一个完整的抽象(这是认真刻苦直接使用),露出它作为了ByteChannel。

Regarding SNI, the library does the parsing of the first bytes before creating the SSLEngine. 关于SNI,该库在创建SSLEngine之前先解析第一个字节。 The user can then supply a function to the server channel, to select SSLContexts depending on the received domain name. 然后,用户可以向服务器通道提供功能,以根据接收的域名选择SSLContexts。

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

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