diff --git a/ChangeLog b/ChangeLog index fac39c3..1a8c6ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ - IPv6 support - Old style SSL support - New API xmpp_uuid_gen() + - New API xmpp_conn_is_secured() 0.8.8 - XML namespace support diff --git a/examples/basic.c b/examples/basic.c index ff17799..8c0f3a4 100644 --- a/examples/basic.c +++ b/examples/basic.c @@ -21,9 +21,13 @@ void conn_handler(xmpp_conn_t * const conn, const xmpp_conn_event_t status, void * const userdata) { xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata; + int secured; if (status == XMPP_CONN_CONNECT) { fprintf(stderr, "DEBUG: connected\n"); + secured = xmpp_conn_is_secured(conn); + fprintf(stderr, "DEBUG: connection is %s.\n", + secured ? "secured" : "NOT secured"); xmpp_disconnect(conn); } else { @@ -74,7 +78,7 @@ int main(int argc, char **argv) /* create a connection */ conn = xmpp_conn_new(ctx); - /* configure connection properties */ + /* configure connection properties (optional) */ if (opt_disable_tls) xmpp_conn_disable_tls(conn); if (opt_old_ssl) diff --git a/src/conn.c b/src/conn.c index a26adb3..15b0662 100644 --- a/src/conn.c +++ b/src/conn.c @@ -788,6 +788,12 @@ void xmpp_conn_set_old_style_ssl(xmpp_conn_t * const conn) conn->tls_is_old_ssl = 1; } +/** Returns whether TLS session is established or not. */ +int xmpp_conn_is_secured(xmpp_conn_t * const conn) +{ + return conn->secured && !conn->tls_failed ? 1 : 0; +} + static void _log_open_tag(xmpp_conn_t *conn, char **attrs) { char buf[4096]; diff --git a/strophe.h b/strophe.h index cebd234..5d1d7d7 100644 --- a/strophe.h +++ b/strophe.h @@ -216,6 +216,7 @@ void xmpp_conn_set_pass(xmpp_conn_t * const conn, const char * const pass); xmpp_ctx_t* xmpp_conn_get_context(xmpp_conn_t * const conn); void xmpp_conn_disable_tls(xmpp_conn_t * const conn); void xmpp_conn_set_old_style_ssl(xmpp_conn_t * const conn); +int xmpp_conn_is_secured(xmpp_conn_t * const conn); int xmpp_connect_client(xmpp_conn_t * const conn, const char * const altdomain,