SSL_connect/从“空”读取生物
我在底层套接字(在本例中为 (lib)ssh2 隧道通道)和 BIO 之间建立链接以进行握手时遇到问题。
所有麻烦的原因是:我希望握手的服务器最初不是 SSL 加密服务器,并且必须在 SSL_connect()'ing/握手之前被告知打开 SSL。具体来说,它是一个带有 SSL 扩展的 FTP 服务器。
我在下面提供我的代码(在咖啡馆的帮助下)。
首先建立一个隧道通道,在该通道上发送 SSL 加密的初始请求(明文的“AUTH SSL”)。当我尝试协商握手时,困难就出现了,因为在我看来,没有数据可供握手。
代码: http://pastebin.com/TG8RMyWx
不知何故,我似乎需要在通道和 BIO 之间传输数据”在”握手期间,但我看不到怎么办?
我已经能够仅使用一个 BIO(作为本地主机的套接字)建立到外部 SSH 隧道的 SSL 连接(只需运行 OpenSSH 的 ssh -f user@host -L 21:remote_host:21 -N),所以我我猜我的麻烦在于上一段所述的携带。
非常感谢任何提示,谢谢!
- 詹姆斯
I have a problem making the link between the underlying socket (in this case, a (lib)ssh2 tunnel channel) and the BIO in order to make a handshake.
The reason for all the trouble is: the server I wish to handshake with is not an SSL encrypted server initially, and has to be told to turn on SSL before SSL_connect()'ing/handshaking. Specifically it's a FTP server with SSL extension.
I'm providing my code (with help from caf) below.
First a tunnel channel is set up, on which the initial request for SSL encryption is send ("AUTH SSL" in plaintext). The difficulties arise when I try to negotiate the handshake because, as I see it, there is no data to do handshaking upon.
Code:
http://pastebin.com/TG8RMyWx
Somehow it would seem I need to carry the data between channel and BIO "during" the handshake, but I fail to see how?
I've been able to set up a SSL connection to an external SSH tunnel (simply ran OpenSSH's ssh -f user@host -L 21:remote_host:21 -N) with just one BIO (as socket to the localhost), so I'm guessing my troubles is in the carrying as stated in the previous paragraph.
Any hints are greatly appreciated, thanks!
- James
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我现在可以看到两件事:
您的 BIO 未正确初始化。使用
BIO_new_bio_pair(&rbio, 0, &wbio, 0);
而不是BIO_make_bio_pair()
调用;一旦你解决了这个问题,
SSL_connect()
将返回SSL_ERROR_WANT_READ
/SSL_ERROR_WANT_WRITE
- 然后你需要将其放入循环,如SSL_read()
。Two things I can see now:
Your BIOs aren't initialised properly. Use
BIO_new_bio_pair(&rbio, 0, &wbio, 0);
instead of yourBIO_make_bio_pair()
call;Once you've fixed that, then
SSL_connect()
will returnSSL_ERROR_WANT_READ
/SSL_ERROR_WANT_WRITE
- you then will need to put it into a loop, like theSSL_read()
.