Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valuable error code from openSSL is discarded #705

Open
EdFuentetaja opened this issue Feb 18, 2018 · 1 comment
Open

Valuable error code from openSSL is discarded #705

EdFuentetaja opened this issue Feb 18, 2018 · 1 comment

Comments

@EdFuentetaja
Copy link

EdFuentetaja commented Feb 18, 2018

First of all, thank you for sharing this fantastic library. I was using it today on a secured websocket server when one client failed to connect. The server reported "TLS handshake failed," error code 8. I spend quite a bit of time debugging until I've found that in fact the error code reported by openSSL is 336109761, which means "no shared cipher," a lot more precise and the clue that put me in the right track to fix this problem.

The issue is with the handle_init method on the connection class (tls.hpp):

    void handle_init(init_handler callback,lib::asio::error_code const & ec) {
        if (ec) {
            m_ec = socket::make_error_code(socket::error::tls_handshake_failed);
        } else {
            m_ec = lib::error_code();
        }

        callback(m_ec);
    }

The arriving ec value is 336109761 but it's discarded and replaced by a generic tls_handshake_failed.

Please don't discard this value, it can be extremely useful. I don't know the consequences of just assigning ec to m_ec.

For your consideration. Thanks a lot,

Ed

@zaphoyd
Copy link
Owner

zaphoyd commented Feb 19, 2018

Yeah, this is a tougher one. m_ec is of a different type than ec so they cannot be reliably assigned to each other without the library copying (and maintaining a list of) all of the security policy error codes (which could be Asio, raw Open/LibreSSL, custom policies written by end users, etc.

Other portions of the code print the raw error message to one of the log channels before generic code translation, but the security policy doesn't have access to the logger so this is not straight forward.

That said, OpenSSL errors are a pain even with the codes, so yes, this really should be fixed some way or another.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants