File tree Expand file tree Collapse file tree 4 files changed +12
-3
lines changed Expand file tree Collapse file tree 4 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -825,7 +825,8 @@ static void _auth(xmpp_conn_t *conn)
825825
826826 /* SASL algorithm was tried, unset flag */
827827 conn -> sasl_support &= ~scram_ctx -> alg -> mask ;
828- } else if (conn -> sasl_support & SASL_MASK_DIGESTMD5 ) {
828+ } else if ((conn -> sasl_support & SASL_MASK_DIGESTMD5 ) &&
829+ conn -> weak_auth_enabled ) {
829830 auth = _make_sasl_auth (conn , "DIGEST-MD5" );
830831 if (!auth ) {
831832 disconnect_mem_error (conn );
@@ -839,7 +840,8 @@ static void _auth(xmpp_conn_t *conn)
839840
840841 /* SASL DIGEST-MD5 was tried, unset flag */
841842 conn -> sasl_support &= ~SASL_MASK_DIGESTMD5 ;
842- } else if (conn -> sasl_support & SASL_MASK_PLAIN ) {
843+ } else if ((conn -> sasl_support & SASL_MASK_PLAIN ) &&
844+ conn -> weak_auth_enabled ) {
843845 auth = _make_sasl_auth (conn , "PLAIN" );
844846 if (!auth ) {
845847 disconnect_mem_error (conn );
Original file line number Diff line number Diff line change @@ -232,6 +232,7 @@ struct _xmpp_conn_t {
232232 int sasl_support ; /* if true, field is a bitfield of supported
233233 mechanisms */
234234 int auth_legacy_enabled ;
235+ int weak_auth_enabled ;
235236 int secured ; /* set when stream is secured with TLS */
236237 xmpp_certfail_handler certfail_handler ;
237238 xmpp_password_callback password_callback ;
Original file line number Diff line number Diff line change @@ -1112,7 +1112,8 @@ long xmpp_conn_get_flags(const xmpp_conn_t *conn)
11121112 XMPP_CONN_FLAG_LEGACY_SSL * conn -> tls_legacy_ssl |
11131113 XMPP_CONN_FLAG_TRUST_TLS * conn -> tls_trust |
11141114 XMPP_CONN_FLAG_DISABLE_SM * conn -> sm_disable |
1115- XMPP_CONN_FLAG_LEGACY_AUTH * conn -> auth_legacy_enabled ;
1115+ XMPP_CONN_FLAG_LEGACY_AUTH * conn -> auth_legacy_enabled |
1116+ XMPP_CONN_FLAG_WEAK_AUTH * conn -> weak_auth_enabled ;
11161117
11171118 return flags ;
11181119}
@@ -1161,6 +1162,7 @@ int xmpp_conn_set_flags(xmpp_conn_t *conn, long flags)
11611162 conn -> tls_trust = (flags & XMPP_CONN_FLAG_TRUST_TLS ) ? 1 : 0 ;
11621163 conn -> auth_legacy_enabled = (flags & XMPP_CONN_FLAG_LEGACY_AUTH ) ? 1 : 0 ;
11631164 conn -> sm_disable = (flags & XMPP_CONN_FLAG_DISABLE_SM ) ? 1 : 0 ;
1165+ conn -> weak_auth_enabled = (flags & XMPP_CONN_FLAG_WEAK_AUTH ) ? 1 : 0 ;
11641166
11651167 return 0 ;
11661168}
Original file line number Diff line number Diff line change @@ -191,6 +191,10 @@ typedef struct _xmpp_sm_t xmpp_sm_state_t;
191191 * Disable Stream-Management XEP-0198.
192192 */
193193#define XMPP_CONN_FLAG_DISABLE_SM (1UL << 5)
194+ /** @def XMPP_CONN_FLAG_WEAK_AUTH
195+ * Allow weak authentication methods (DIGEST-MD5 and PLAIN).
196+ */
197+ #define XMPP_CONN_FLAG_WEAK_AUTH (1UL << 6)
194198
195199/* connect callback */
196200typedef enum {
You can’t perform that action at this time.
0 commit comments