How to decipher a boost asio ssl error code?

我怕爱的太早我们不能终老 提交于 2019-11-30 20:09:47

they use ERR_PACK from crypto/err/err.h

this will allow converting error to string

#include <crypto/err/err.h>

string err = error.message()
if (error.category() == boost::asio::error::get_ssl_category()) {
    err = string(" (")
            +boost::lexical_cast<string>(ERR_GET_LIB(error.value()))+","
            +boost::lexical_cast<string>(ERR_GET_FUNC(error.value()))+","
            +boost::lexical_cast<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;
}

Probably not included in boost so asio does not need link to ssl when using pure sockets

Gearoid Murphy

I eventually gained some insight into the problem by building openssl in debug and putting a breakpoint on the OpenSSL error reporting function ERR_put_error.

The callstack showed that the problem was originating from SSL_read, caused by the fact that the handshake function had not been initialized. The actual error number used by the ERR_put_error function is 276, how boost manages to mangle this into 336458004 is beyond me. The bug itself was caused by a a global flag which I was using to toggle the SSL functions as I tunnel through a proxy onto a remote HTTPS server.

Hope this helps someone.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!