我在Qt
中有这段代码QFile file(address);
file.open(QIODevice::ReadOnly);
const QByteArray bytes = file.readAll();
qDebug()<<"Length : " + QString::number(bytes.length());
const QSslCertificate cert(bytes,QSsl::Der);
当我在Windows 7 64bit中尝试此代码时,它工作得很好但是当我为linux编译它时,每当它击中最后一行时崩溃,即使它给了我正确的长度,但它在终端中与这些行崩溃。
qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_client_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_client_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_server_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_server_method
qt.network.ssl: QSslSocket: cannot resolve SSL_select_next_proto
qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_next_proto_select_cb
qt.network.ssl: QSslSocket: cannot resolve SSL_get0_next_proto_negotiated
qt.network.ssl: QSslSocket: cannot resolve EC_KEY_new_by_curve_name
qt.network.ssl: QSslSocket: cannot resolve EC_KEY_free
Segmentation fault (core dumped)
在这里发生的事情我没有在我的代码中使用任何QSslSocket,现在我已经陷入了这个问题几天了。
qt版本5.4.2在Ubuntu 13.10 64位和CentOS 6.4 64位
更新
我在Windows和Linux上都使用openssl-1.0.2d。
答案 0 :(得分:2)
我找到了解决方案,我做的是:
OpenSSL 1.1.0与QT不兼容所以我克隆了1.0.1稳定版: 这是错误:https://bugreports.qt.io/browse/QTBUG-52905
git clone https://github.com/openssl/openssl -b OpenSSL_1_0_1-stable
然后将其安装在自定义位置:
./config --prefix=/opt/openssl-stable
make
make test
sudo make install
获取QT源,然后当您想要构建它们时,您必须链接已安装的OpenSSL:
OPENSSL_LIBS='-L/opt/ssl/lib -lssl -lcrypto' ./configure -openssl-linked
请参阅:http://doc.qt.io/qt-5/ssl.html
这是我的配置:
OPENSSL_LIBS='-L/opt/openssl-stable/lib -lssl -lcrypto' ./configure -prefix /opt/qt5.7_linux_staticssl -opensource -confirm-license -release -openssl-linked -I /opt/openssl-stable/include/openssl -L /opt/openssl-stable/lib
如果qt构建给你一个错误,它没有找到一些ssl结构,只需将/ opt / openssl-stable / include / openssl标题复制到/ usr / include / openssl或qt正在查找的地方对于他们(你可以看到当qt构建失败时)
那就是