我在 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/