Thrift 在 SSL_accept 上随机崩溃
Thrift random crashes on SSL_accept
我正在用 C++ 开发客户端和线程服务器,但我遇到了 OpenSSL/TLS 集成问题。
到目前为止,我已经按照 ThriftServer.cpp 和 ThriftClient.cpp 进行操作,但我遇到了导致我的应用程序崩溃的随机错误。
具体来说,当客户端尝试调用服务器上定义的 thrift 接口(已经生效)时会发生崩溃
/* server init with PEM public/private certificates
* and trusted certificates, socketFactory->accept(true),
* transport->open() */
myServer->start(); //running on separated thread, calling thriftserver->serve();
/* client init with PEM public/private certificates
* and trusted certificates, socketFactory->accept(true),
* transport->open() */
myClient->beginSession(); //Thrift API call - crash
崩溃真的很普遍:有时它给我
TConnectedClient died: SSL_accept: error 0
有时
TConnectedClient died: SSL_accept: parse tlsext
并且都以 SIGSEV 结尾。
我是 运行 Debian 8.1 x64,最新的 OpenSSL 1.0.2d 从源代码编译并标记 enable-tlsext,来自 github/trunk 和 libevent 的节俭来自 github/trunk.
我已经尝试了我的自定义自签名证书和 Thrift 附带的测试证书:在这两种情况下它都不起作用,但它们正在使用 openssl s_client 和 openssl s_server
知道这些错误的原因吗?
编辑
我编译了支持线程的 OpenSSL(./configure 上的线程标志),现在我的应用程序总是触发错误
SSL_shutdown: broken pipe
当客户端尝试联系服务器时。深入挖掘,openssl s_client 触发
sslv3 alert handshake failure
使用 TLSv1.2 作为协议。我已经检查了 问题,但它没有帮助,只要我已经在使用最新的 OpenSSL 快照
关于SSL_shutdown问题,根据这个document,你应该忽略SIGPIPE信号以避免服务器崩溃:
SIGPIPE signal
Applications running OpenSSL over network connections may crash if SIGPIPE is not ignored. This happens when they receive a connection reset by remote peer exception, which somehow triggers a SIGPIPE signal. If not handled, this signal would kill the application.
这可以通过以下方式完成:
#include <csignal>
// ...
signal(SIGPIPE, SIG_IGN);
我正在用 C++ 开发客户端和线程服务器,但我遇到了 OpenSSL/TLS 集成问题。
到目前为止,我已经按照 ThriftServer.cpp 和 ThriftClient.cpp 进行操作,但我遇到了导致我的应用程序崩溃的随机错误。 具体来说,当客户端尝试调用服务器上定义的 thrift 接口(已经生效)时会发生崩溃
/* server init with PEM public/private certificates
* and trusted certificates, socketFactory->accept(true),
* transport->open() */
myServer->start(); //running on separated thread, calling thriftserver->serve();
/* client init with PEM public/private certificates
* and trusted certificates, socketFactory->accept(true),
* transport->open() */
myClient->beginSession(); //Thrift API call - crash
崩溃真的很普遍:有时它给我
TConnectedClient died: SSL_accept: error 0
有时
TConnectedClient died: SSL_accept: parse tlsext
并且都以 SIGSEV 结尾。
我是 运行 Debian 8.1 x64,最新的 OpenSSL 1.0.2d 从源代码编译并标记 enable-tlsext,来自 github/trunk 和 libevent 的节俭来自 github/trunk.
我已经尝试了我的自定义自签名证书和 Thrift 附带的测试证书:在这两种情况下它都不起作用,但它们正在使用 openssl s_client 和 openssl s_server
知道这些错误的原因吗?
编辑
我编译了支持线程的 OpenSSL(./configure 上的线程标志),现在我的应用程序总是触发错误
SSL_shutdown: broken pipe
当客户端尝试联系服务器时。深入挖掘,openssl s_client 触发
sslv3 alert handshake failure
使用 TLSv1.2 作为协议。我已经检查了
关于SSL_shutdown问题,根据这个document,你应该忽略SIGPIPE信号以避免服务器崩溃:
SIGPIPE signal
Applications running OpenSSL over network connections may crash if SIGPIPE is not ignored. This happens when they receive a connection reset by remote peer exception, which somehow triggers a SIGPIPE signal. If not handled, this signal would kill the application.
这可以通过以下方式完成:
#include <csignal>
// ...
signal(SIGPIPE, SIG_IGN);