Strophe Unrecoverable TLS error

846 Views Asked by At

I am developing a simple ejabberd client in C using libstrophe. It connects and begins to handle messages as it's supposed to do.

However, after a while (following two or three pings from the ejabberd server), my connection closes and the status is set to DISCONNECTED. Below is the tail of the debug lines:

xmpp DEBUG Unrecoverable TLS error, 5. 
xmpp DEBUG Closing socket.
DEBUG: disconnected event DEBUG Stopping event loop. 
event DEBUG Event
oop completed.

I initialize and connect as below.

xmpp_initialize();

/* read connection params */
if( set_xmpp_conn_params( &conn_params ) < 0 ) {
    fprintf(stderr, "Could not retrieve connection params from %s\n", 
                    SERVER_CONF_FILE);
    return -1;
}

/* initialize the XMPP logger */
xmpp_log = xmpp_get_default_logger(XMPP_LOG_LEVEL);
xmpp_ctx = xmpp_ctx_new(NULL, xmpp_log);

/* create a connection */
xmpp_conn = xmpp_conn_new(xmpp_ctx);

/* login */
xmpp_conn_set_jid(xmpp_conn, conn_params.jid);
xmpp_conn_set_pass(xmpp_conn, conn_params.password);

/* create a client */
xmpp_connect_client(    xmpp_conn, conn_params.host, 0, 
                        agent_conn_handler, xmpp_ctx );

/* enter the event loop */
xmpp_run( xmpp_ctx );

/*  the code below is executed 
    whenever connection handler @agent_conn_handler exits */

/* release the connection and context */
xmpp_conn_release(xmpp_conn);
xmpp_ctx_free(xmpp_ctx);

Why am I getting that TLS error message?

Thanks.

1

There are 1 best solutions below

3
On

Error 5 is SSL_ERROR_SYSCALL. The OpenSSL docs say:

Some I/O error occurred. The OpenSSL error queue may contain more information on the error. If the error queue is empty (i.e. ERR_get_error() returns 0), ret can be used to find out more about the error: If ret == 0, an EOF was observed that violates the protocol. If ret == -1, the underlying BIO reported an I/O error (for socket I/O on Unix systems, consult errno for details).

In practice, this may mean the server dropped your connection for some reason. I'd suggest doing a packet trace with WireShark to get more info. For example, we have seen this happen with servers that use the RSA libraries for TLS, when the client offers TLS version 1.1.