c++ - 如何破译 boost asio ssl 错误代码?

标签 c++ boost ssl boost-asio

我在 boost asio ssl 实现中偶尔会遇到通信失败,boost 返回的 super 有用的错误消息是“asio.ssl:336458004”

我怀疑数字是某种由 SSL 标志组成的聚合结构,我说是因为 linux 错误代码、boost asio 错误代码和 ssl 错误代码没有任何对“336458004”的引用,所以大概它必须是动态构建的。

任何人都可以提供一些关于我应该如何破译此错误代码的见解吗?谢谢。

最佳答案

他们使用来自 crypto/err/err.h 的 ERR_PACK

这将允许将错误转换为字符串

#include <crypto/err/err.h>

std::string err = error.message();
if (error.category() == boost::asio::error::get_ssl_category()) {
    err = std::string(" (")
            +boost::lexical_cast<std::string>(ERR_GET_LIB(error.value()))+","
            +boost::lexical_cast<std::string>(ERR_GET_FUNC(error.value()))+","
            +boost::lexical_cast<std::string>(ERR_GET_REASON(error.value()))+") "
    ;
    //ERR_PACK /* crypto/err/err.h */
    char buf[128];
    ::ERR_error_string_n(error.value(), buf, sizeof(buf));
    err += buf;
}

可能不包含在 boost 中,因此 asio 在使用纯套接字时不需要链接到 ssl

关于c++ - 如何破译 boost asio ssl 错误代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9828066/

相关文章:

java - SWIG:使用导入的外部类型

c++ - boost::hash包含元组的元组

c++ - 如何为 boost::program_options 的位置选项添加描述?

ssl - 在单声道中,如何控制 SSL/TLS 密码套件?

linux - Apache 客户端身份验证 : Certificate Verification: Error (2): unable to get issuer certificate (SOLVE)

node.js 我可以为同一个项目使用多个 ssl 证书和 key 吗?如何使用?

c++ - 将矩阵转换为数组

c++ - 控制不同的硬件 : multithreading or something different?

c++ - 流网络摄像头速度慢 "detectMultiScale"

c++ - 在导致 undefined symbol 错误的示例代码上使用 Boost 库?