- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我目前正在开发一个 C++ IMAP 库,这样我就可以改进一些公认的生锈的 C++ 技能。我想让这个库尽可能便携,这样我就可以跨操作系统使用它,如果我觉得疯狂,甚至可以在移动设备上使用它。为此,我做了一些研究并决定使用 Boost 的 Asio 库。
我能够让 Boost 自行在我的项目中构建和运行。我对 google.com 做了一个简单的 HTTP GET。不幸的是,我需要能够使用 TLS 进行通信,并且在尝试使用 Asio 的 SSL 功能时遇到了问题。
我使用默认设置从源代码构建了 Boost 和 OpenSSL(所以一切都在/usr/local 中)。我也在使用 CMAKE 来构建我的项目。下面是我的 CMAKE 文件:
cmake_minimum_required(VERSION 3.2)
project(IMAP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
message(WARNING "Starting CMAKE...")
set(SOURCE_FILES main.cpp)
add_executable(IMAP ${SOURCE_FILES})
find_package(Boost COMPONENTS system thread regex REQUIRED)
message(WARNING "Boost_INCLUDE_DIR: ${Boost_INCLUDE_DIR}")
message(WARNING "Boost_LIBRARIES: ${Boost_LIBRARIES}")
message(WARNING "Boost_VERSION: ${Boost_VERSION}")
include_directories(${Boost_INCLUDE_DIR})
target_link_libraries(IMAP ${Boost_LIBRARIES})
find_package(OpenSSL REQUIRED)
message(WARNING "OpenSSL_VERSION: ${OPENSSL_VERSION}")
message(WARNING "OpenSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}")
message(WARNING "OpenSSL_LIBRARIES: ${OPENSSL_LIBRARIES}")
include_directories(${OPENSSL_INCLUDE_DIR})
target_link_libraries(IMAP ${OPENSSL_LIBRARIES})
这是我的 CMAKE 消息的输出:
Warning:Starting CMAKE...
Warning:Boost_INCLUDE_DIR: /usr/local/include
Warning:Boost_LIBRARIES: /usr/local/lib/libboost_system.dylib;/usr/local/lib/libboost_thread.dylib;/usr/local/lib/libboost_regex.dylib;/usr/local/lib/libboost_chrono.dylib;/usr/local/lib/libboost_date_time.dylib;/usr/local/lib/libboost_atomic.dylib
Warning:Boost_VERSION: 106100
Warning:OpenSSL_VERSION: 1.1.0
Warning:OpenSSL_INCLUDE_DIR: /usr/local/include
Warning:OpenSSL_LIBRARIES: /usr/local/lib/libssl.dylib;/usr/local/lib/libcrypto.dylib
当我尝试构建项目时,我收到以下一堆错误:
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:29:
In file included from /usr/local/include/boost/asio/ssl/detail/openssl_init.hpp:100:
/usr/local/include/boost/asio/ssl/detail/impl/openssl_init.ipp:43:23: error: expected unqualified-id
mutexes_.resize(::CRYPTO_num_locks());
^
/usr/local/include/openssl/crypto.h:218:41: note: expanded from macro 'CRYPTO_num_locks'
# define CRYPTO_num_locks() (0)
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:29:
In file included from /usr/local/include/boost/asio/ssl/detail/openssl_init.hpp:100:
/usr/local/include/boost/asio/ssl/detail/impl/openssl_init.ipp:46:66: error: expected unqualified-id
::CRYPTO_set_locking_callback(&do_init::openssl_locking_func);
^
/usr/local/include/boost/asio/ssl/detail/impl/openssl_init.ipp:47:56: error: expected unqualified-id
::CRYPTO_set_id_callback(&do_init::openssl_id_func);
^
/usr/local/include/boost/asio/ssl/detail/impl/openssl_init.ipp:64:32: error: expected unqualified-id
::CRYPTO_set_id_callback(0);
^
/usr/local/include/boost/asio/ssl/detail/impl/openssl_init.ipp:65:37: error: expected unqualified-id
::CRYPTO_set_locking_callback(0);
^
/usr/local/include/boost/asio/ssl/detail/impl/openssl_init.ipp:66:7: error: expected unqualified-id
::ERR_free_strings();
^
/usr/local/include/openssl/err.h:241:29: note: expanded from macro 'ERR_free_strings'
# define ERR_free_strings() while(0) continue
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:29:
In file included from /usr/local/include/boost/asio/ssl/detail/openssl_init.hpp:100:
/usr/local/include/boost/asio/ssl/detail/impl/openssl_init.ipp:68:7: warning: 'ERR_remove_thread_state' is deprecated [-Wdeprecated-declarations]
::ERR_remove_thread_state(NULL);
^
/usr/local/include/openssl/err.h:244:25: note: 'ERR_remove_thread_state' has been explicitly marked deprecated here
DEPRECATEDIN_1_1_0(void ERR_remove_thread_state(void *))
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:29:
In file included from /usr/local/include/boost/asio/ssl/detail/openssl_init.hpp:100:
/usr/local/include/boost/asio/ssl/detail/impl/openssl_init.ipp:72:7: error: expected unqualified-id
::EVP_cleanup();
^
/usr/local/include/openssl/evp.h:865:25: note: expanded from macro 'EVP_cleanup'
# define EVP_cleanup() while(0) continue
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:29:
In file included from /usr/local/include/boost/asio/ssl/detail/openssl_init.hpp:100:
/usr/local/include/boost/asio/ssl/detail/impl/openssl_init.ipp:73:7: error: expected unqualified-id
::CRYPTO_cleanup_all_ex_data();
^
/usr/local/include/openssl/crypto.h:206:39: note: expanded from macro 'CRYPTO_cleanup_all_ex_data'
# define CRYPTO_cleanup_all_ex_data() while(0) continue
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:29:
In file included from /usr/local/include/boost/asio/ssl/detail/openssl_init.hpp:100:
/usr/local/include/boost/asio/ssl/detail/impl/openssl_init.ipp:76:7: error: expected unqualified-id
::ENGINE_cleanup();
^
/usr/local/include/openssl/engine.h:508:27: note: expanded from macro 'ENGINE_cleanup'
# define ENGINE_cleanup() while(0) continue
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:29:
In file included from /usr/local/include/boost/asio/ssl/detail/openssl_init.hpp:100:
/usr/local/include/boost/asio/ssl/detail/impl/openssl_init.ipp:106:16: error: use of undeclared identifier 'CRYPTO_LOCK'
if (mode & CRYPTO_LOCK)
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:786:
/usr/local/include/boost/asio/ssl/impl/context.ipp:83:31: error: no member named 'SSLv2_method' in the global namespace
handle_ = ::SSL_CTX_new(::SSLv2_method());
~~^
/usr/local/include/boost/asio/ssl/impl/context.ipp:86:31: error: no member named 'SSLv2_client_method' in the global namespace
handle_ = ::SSL_CTX_new(::SSLv2_client_method());
~~^
/usr/local/include/boost/asio/ssl/impl/context.ipp:89:31: error: no member named 'SSLv2_server_method' in the global namespace
handle_ = ::SSL_CTX_new(::SSLv2_server_method());
~~^
/usr/local/include/boost/asio/ssl/impl/context.ipp:111:31: warning: 'TLSv1_method' is deprecated [-Wdeprecated-declarations]
handle_ = ::SSL_CTX_new(::TLSv1_method());
^
/usr/local/include/openssl/ssl.h:1556:45: note: 'TLSv1_method' has been explicitly marked deprecated here
DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_method(void)) /* TLSv1.0 */
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:786:
/usr/local/include/boost/asio/ssl/impl/context.ipp:114:31: warning: 'TLSv1_client_method' is deprecated [-Wdeprecated-declarations]
handle_ = ::SSL_CTX_new(::TLSv1_client_method());
^
/usr/local/include/openssl/ssl.h:1558:45: note: 'TLSv1_client_method' has been explicitly marked deprecated here
DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_client_method(void)) /* TLSv1.0 */
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:786:
/usr/local/include/boost/asio/ssl/impl/context.ipp:117:31: warning: 'TLSv1_server_method' is deprecated [-Wdeprecated-declarations]
handle_ = ::SSL_CTX_new(::TLSv1_server_method());
^
/usr/local/include/openssl/ssl.h:1557:45: note: 'TLSv1_server_method' has been explicitly marked deprecated here
DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_server_method(void)) /* TLSv1.0 */
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:786:
/usr/local/include/boost/asio/ssl/impl/context.ipp:130:31: warning: 'TLSv1_1_method' is deprecated [-Wdeprecated-declarations]
handle_ = ::SSL_CTX_new(::TLSv1_1_method());
^
/usr/local/include/openssl/ssl.h:1562:45: note: 'TLSv1_1_method' has been explicitly marked deprecated here
DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_method(void)) /* TLSv1.1 */
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:786:
/usr/local/include/boost/asio/ssl/impl/context.ipp:133:31: warning: 'TLSv1_1_client_method' is deprecated [-Wdeprecated-declarations]
handle_ = ::SSL_CTX_new(::TLSv1_1_client_method());
^
/usr/local/include/openssl/ssl.h:1564:45: note: 'TLSv1_1_client_method' has been explicitly marked deprecated here
DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_client_method(void)) /* TLSv1.1 */
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:786:
/usr/local/include/boost/asio/ssl/impl/context.ipp:136:31: warning: 'TLSv1_1_server_method' is deprecated [-Wdeprecated-declarations]
handle_ = ::SSL_CTX_new(::TLSv1_1_server_method());
^
/usr/local/include/openssl/ssl.h:1563:45: note: 'TLSv1_1_server_method' has been explicitly marked deprecated here
DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_server_method(void)) /* TLSv1.1 */
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:786:
/usr/local/include/boost/asio/ssl/impl/context.ipp:148:31: warning: 'TLSv1_2_method' is deprecated [-Wdeprecated-declarations]
handle_ = ::SSL_CTX_new(::TLSv1_2_method());
^
/usr/local/include/openssl/ssl.h:1568:45: note: 'TLSv1_2_method' has been explicitly marked deprecated here
DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_method(void)) /* TLSv1.2 */
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:786:
/usr/local/include/boost/asio/ssl/impl/context.ipp:151:31: warning: 'TLSv1_2_client_method' is deprecated [-Wdeprecated-declarations]
handle_ = ::SSL_CTX_new(::TLSv1_2_client_method());
^
/usr/local/include/openssl/ssl.h:1570:45: note: 'TLSv1_2_client_method' has been explicitly marked deprecated here
DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_client_method(void)) /* TLSv1.2 */
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:786:
/usr/local/include/boost/asio/ssl/impl/context.ipp:154:31: warning: 'TLSv1_2_server_method' is deprecated [-Wdeprecated-declarations]
handle_ = ::SSL_CTX_new(::TLSv1_2_server_method());
^
/usr/local/include/openssl/ssl.h:1569:45: note: 'TLSv1_2_server_method' has been explicitly marked deprecated here
DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_server_method(void)) /* TLSv1.2 */
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:786:
/usr/local/include/boost/asio/ssl/impl/context.ipp:208:16: error: member access into incomplete type 'SSL_CTX' (aka 'ssl_ctx_st')
if (handle_->default_passwd_callback_userdata)
^
/usr/local/include/openssl/ossl_typ.h:144:16: note: forward declaration of 'ssl_ctx_st'
typedef struct ssl_ctx_st SSL_CTX;
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:786:
/usr/local/include/boost/asio/ssl/impl/context.ipp:212:20: error: member access into incomplete type 'SSL_CTX' (aka 'ssl_ctx_st')
handle_->default_passwd_callback_userdata);
^
/usr/local/include/openssl/ossl_typ.h:144:16: note: forward declaration of 'ssl_ctx_st'
typedef struct ssl_ctx_st SSL_CTX;
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:786:
/usr/local/include/boost/asio/ssl/impl/context.ipp:212:22: error: expected ')'
handle_->default_passwd_callback_userdata);
^
/usr/local/include/boost/asio/ssl/impl/context.ipp:211:53: note: to match this '('
static_cast<detail::password_callback_base*>(
^
/usr/local/include/boost/asio/ssl/impl/context.ipp:214:14: error: member access into incomplete type 'SSL_CTX' (aka 'ssl_ctx_st')
handle_->default_passwd_callback_userdata = 0;
^
/usr/local/include/openssl/ossl_typ.h:144:16: note: forward declaration of 'ssl_ctx_st'
typedef struct ssl_ctx_st SSL_CTX;
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:786:
/usr/local/include/boost/asio/ssl/impl/context.ipp:551:18: error: member access into incomplete type 'SSL_CTX' (aka 'ssl_ctx_st')
handle_->default_passwd_callback,
^
/usr/local/include/openssl/ossl_typ.h:144:16: note: forward declaration of 'ssl_ctx_st'
typedef struct ssl_ctx_st SSL_CTX;
^
In file included from /path/to/my/code/JMail/IMAP/main.cpp:4:
In file included from /path/to/my/code/JMail/IMAP/IMAPClient.h:6:
In file included from /path/to/my/code/JMail/IMAP/TLSSocket.h:9:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:786:
/usr/local/include/boost/asio/ssl/impl/context.ipp:552:18: error: member access into incomplete type 'SSL_CTX' (aka 'ssl_ctx_st')
handle_->default_passwd_callback_userdata) };
^
/usr/local/include/openssl/ossl_typ.h:144:16: note: forward declaration of 'ssl_ctx_st'
typedef struct ssl_ctx_st SSL_CTX;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
10 warnings and 20 errors generated.
被引用的 TLSSocket 类基本上只是 Boost Asio SSL 示例的包装器:
#include <boost/bind.hpp>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
void TLSSocket::connect() {
boost::asio::io_service io_service;
boost::asio::ip::tcp::resolver resolver(io_service);
boost::asio::ip::tcp::resolver::query query(this->address, this->port);
boost::asio::ip::tcp::resolver::iterator iterator = resolver.resolve(query);
boost::asio::ssl::context ctx(boost::asio::ssl::context::tlsv1);
mSocket = new boost::asio::ssl::stream<boost::asio::ip::tcp::socket>(io_service, ctx);
mSocket->set_verify_mode(boost::asio::ssl::verify_peer);
mSocket->set_verify_callback(boost::bind(&TLSSocket::on_verify_certificate, this, _1, _2));
boost::asio::async_connect(mSocket->lowest_layer(), iterator,
boost::bind(&TLSSocket::on_connect, this, boost::asio::placeholders::error));
io_service.run();
}
void TLSSocket::disconnect() {
mSocket->lowest_layer().cancel();
}
TLSSocket::TLSSocket(std::string address, std::string port) {
this->address = address;
this->port = port;
mSocket = nullptr;
}
void *TLSSocket::send(IMAPRequest *request) {
boost::asio::streambuf requestBuff;
std::ostream request_stream(&requestBuff);
request_stream << request->getTag() << " " << request->getCommand() << " " << request->getContent() << "\r\n";
boost::asio::write(*mSocket, requestBuff);
for (; ;) {
boost::array<char, 128> buffer;
boost::system::error_code error;
size_t len = mSocket->read_some(boost::asio::buffer(buffer), error);
if (error == boost::asio::error::eof)
break;
else if (error)
throw boost::system::system_error(error);
std::cout.write(buffer.data(), len);
}
}
void TLSSocket::on_connect(const boost::system::error_code& error){
if(!error) {
try {
mSocket->async_handshake(boost::asio::ssl::stream_base::handshake_type ::client,
boost::bind(&TLSSocket::on_handshake, this, boost::asio::placeholders::error));
} catch (std::exception ex){
std::cout << "Handshaking error: " << ex.what() << "\n";
}
} else {
std::cout << "Connect error: " << error.message() << "\n";
}
}
void TLSSocket::on_handshake(const boost::system::error_code& error){
if(!error){
} else {
std::cout << "Handshaking error: " << error.message() << "\n";
}
}
bool TLSSocket::on_verify_certificate(bool verified, boost::asio::ssl::verify_context &ctx) {
char subject_name[256];
X509* cert = X509_STORE_CTX_get_current_cert(ctx.native_handle());
X509_NAME_oneline(X509_get_subject_name(cert), subject_name, 256);
std::cout << "Verifying " << subject_name << "\n";
return verified;
}
在我看来它甚至没有进入编译的链接阶段,它只是试图为我的 main.cpp 制作 .o 文件。如果我在我的 IDE 中打开它提示的文件之一,IDE 会突出显示语法错误,但我很困惑为什么。
我是不是把 include 的顺序放错了?我的 CMAKE 文件有问题吗?我是否错误地构建了 OpenSSL 或 Boost?
如有任何帮助,我们将不胜感激。我断断续续地研究了几个星期,大部分时间都花在了构建上(我猜是 C++ 第一课 :))。
最佳答案
在我看来,Boost 尚未更新为与 OpenSSL 1.1.0 一起使用。 OpenSSL 1.0.2 和 1.1.0 之间有许多 API 更改,它们不完全源兼容。我建议您使用 1.0.2,直到 Boost 更新为可以使用新的 OpenSSL 版本(无论如何仍处于测试阶段)。
关于c++ - boost Asio 和 OpenSSL 1.1.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37517730/
如果我使用open ssl命令 sudo openssl genrsa -out privkey.pem 2048 要生成rsa key ,它仅生成1个文件。这是私钥。我如何获得公钥。 最佳答案 回答
三个不同版本的 openssl 正在同时更新 openssl.org : 0.98, 1.0.0, 1.0.1?它们之间有什么区别,我该如何选择要使用的版本? 最佳答案 https://en.wiki
我有以下命令用于 OpenSSL 生成私钥和公钥: openssl genrsa –aes-128-cbc –out priv.pem –passout pass:[privateKeyPass] 2
我正在尝试使用对应的 gcc (arm-none-eabi-5_4-2016q2) 为 cortex m3 机器交叉编译 openssl。机器应该有能力做 TCP 请求,我们希望在一天结束时做 HTT
我正在尝试使用 openssl dsa 实现,但我对以下细节感到非常困惑: 命令 openssl dsa .... 的选项“-text”:输出中的十六进制数字,我是否正确地假设这些是字节,因此它们是按
我正在尝试制作一个假 CA 并用它签署一个证书以与 stunnel 一起使用(这似乎只是调用 OpenSSL 例程,因此您可能不需要了解该程序来提供帮助:)。然而,stunnel 一直拒绝我的证书,说
不幸的是,Perl 在尝试安装 OpenSSL 的手册页(例如 OpenSSL_1_0_1g)时不知何故遇到了错误。因为我不需要它们 - 我只想使用 OpenSSL 作为 C 库,我想我可以通过完全跳
OpenSSL 中的 BIO 对到底是什么?它的用途是什么?我已经检查过 OpenSSL 文档,但任何细节都很少。 最佳答案 OpenSSL 中的 BIO 类似于文件句柄。您可以使用一对它们来安全地相
openssl ca 和 openssl x509 命令有什么区别?我正在使用它来创建和签署我的 root-ca、intermed-ca 和客户端证书,但是 openssl ca 命令不会在证书上注册
如何(如果有的话)为 OpenSSL 定义一个单一的可信证书文件在 Windows(Win-7,OpenSSL 1.0.1c)上使用 SSL_CERT_FILE 环境变量? 各种研究促使我下载了 Mo
我有一个自签名证书,其中显示了列出的基本约束,但从中生成的签名请求不显示这些属性,例如 [v3_req]。我怎样才能让它可见?我正在使用 openssl 生成证书。 场景: 我使用以下方法创建自签名证
这个问题在这里已经有了答案: Check if a connection is TLSv1 vs SSLv3 (SSL_CIPHER_description/SSL_CIPHER_get_name)
是否有更简单的方法来确定在构建 openssl 期间指定的选项,例如当时是否定义了 OPENSSL_NO_SRTP? 我只能从以下方面获得有限的信息: openssl 版本 -a 命令。但是,如果我只
我们正在与 AWS Nitro 合作,仅提供 3 小时的证书。 我们正在寻找一种可以跳过验证中的过期部分并仍然确认证书链有效的方法。 最佳答案 根据 openssl-verify 文档
嗨,我如何在 Easyphp 中启用 openssl,因为我收到错误消息无法发送。Mailer 错误:缺少扩展:opensslTime:使用 phpmailer 时。谢谢 最佳答案 在您的 php.i
我正在尝试以编程方式读取 OpenSSL 警报消息,但无法找到执行此操作的方法。 OpenSSL API 提供如下功能: const char *SSL_alert_type_string(int v
我跑了openssl speed在我的 Ubuntu 计算机上。一些结果: Doing md4 for 3s on 16 size blocks: 9063888 md4's in 3.00s Doi
我编译了带有cryptodev支持(即硬件加速)的OpenSSL,但不幸的是默认引擎仍然是软件。 time openssl speed -evp aes-128-cbc -engine cryptod
我需要从 RedHat Linux 服务器连接到 Microsoft Dynamics CRM 服务器。地址是xxx.api.crm4.dynamics.com。服务器接受 TLSv1 但不接受 1.
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 上个月关闭。 Improve thi
我是一名优秀的程序员,十分优秀!