SSL_accept() 抛出“无效参数”错误
我正在尝试创建一个客户端/服务器程序,但我发现继续处理数量稀少的 OpenSSL 文档有些困难。
我的问题: SSL_accept
在执行以下代码(简化)时抛出“无效参数”:
SSL* ssl = SSL_new(ctx); // ctx is created earlier
SSL_set_fd(ssl, socket); // socket is created earlier as well
BIO * bio = BIO_new(BIO_s_accept());
BIO_set_fd(bio, socket, BIO_NOCLOSE);
SSL_set_bio(ssl, bio, bio);
SSL_accept(ssl);
我在每次方法调用后检查错误,并且套接字和生物都没有变坏。在我尝试调用 SSL_accept 之前,没有任何迹象表明发生了任何奇怪的情况。我假设 ssl 对象在途中的某个地方被损坏,但我不知道如何〜
编辑 SSL 对象和 BIO 对象不为空在调用 SSL_accept() 时。
任何正确方向的指针将不胜感激:D
I'm attempting to create a client/server program, but I'm finding some difficulty continuing with the unfortunately sparse amount of OpenSSL documentation.
My issue:SSL_accept
throws an "Invalid Argument" upon executing the following code (simplified):
SSL* ssl = SSL_new(ctx); // ctx is created earlier
SSL_set_fd(ssl, socket); // socket is created earlier as well
BIO * bio = BIO_new(BIO_s_accept());
BIO_set_fd(bio, socket, BIO_NOCLOSE);
SSL_set_bio(ssl, bio, bio);
SSL_accept(ssl);
I check errors after each method call, and the neither the socket nor the bio goes bad. There's no indication that anything odd is happening until I attempt calling SSL_accept. I assume that the ssl object was corrupted somewhere along the way, but I don't have a clue as to how~
Edit The SSL object and the BIO object are not null at the point of calling SSL_accept().
Any pointers in the right direction would be greatly appreciated :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SSL_set_fd()
旨在作为手动设置 BIO 的便捷替代方法。它会自动创建 BIO 并进行设置 - 所以您需要做的就是:SSL_set_fd()
is meant as a convenient alternative to manually setting up the BIOs. It automatically creates a BIO and sets it up - so all you need to do is:和你一样,我也因缺乏文档而经历了一段困难时期。所以我不能说
set_fd
调用是错误还是正确,但我在没有这些调用的情况下也能正常工作。我成功使用的调用顺序是:Like you, I have had a difficult time with the dearth of documentation. So I can't say whether or not the
set_fd
calls are wrong or right, but I got it working without those. The sequence of calls that I have used successfully is: