SSL和SocketChannel [英] SSL and SocketChannel
问题描述
理想情况下,我只需要一个简单的 SSLSocketChannel
。
Ideally, I only need a simple SSLSocketChannel
.
我已经有一个组件可以通过普通的 SocketChannel
读取和写入消息,但对于其中一些连接,我必须在线上使用SSL;但是,这些连接上的操作是相同的。
I already have a component that reads and writes message over ordinary SocketChannel
, but for some of these connections, I have to use SSL over the wire; the operations over these connections, however, are the same.
有没有人知道免费的 SSLSocketChannel
实现(使用适当的选择器)或类似的东西?我找到了这个,但是选择器不接受它,因为它的供应商不是SUN。
Does anyone knows a free SSLSocketChannel
implementation (with the appropriate selector) or something similar? I've found this, but the selector doesn't accept it since its vendor isn't SUN.
我正在将read_from / writing_to网络逻辑与通过网络数据的插入和检索解耦简单的对象,为了使用 SSLEngine
而不会生气,但考虑到我不了解SSL协议的内部这一点,实现它是非常棘手的。 ..
I'm decoupling the reading_from/writing_to net logic from the insertion and retrieval of network data via a simple object, in order to use a SSLEngine
without getting mad, but it's really tricky to implement that correctly, given the fact that I don't know the internals of SSL protocol...
推荐答案
查看Restlet的实现,它可以做你需要的,而且都是关于NIO的。
Check out Restlet's implementation it may do what you need, and it's all about NIO.
特别是HttpClientCall。 SetProtocol(HTTPS) - getResponseEntityChannel返回一个ReadableByteChannel(getEntityChannel返回一个WriteableByteChannel)
Specifically the HttpClientCall. SetProtocol(HTTPS) - getResponseEntityChannel returns a ReadableByteChannel (getEntityChannel returns a WriteableByteChannel)
这篇关于SSL和SocketChannel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!