37
37
#ifdef MONGOC_ENABLE_SASL
38
38
#include "mongoc-sasl-private.h"
39
39
#endif
40
+ #include "mongoc-b64-private.h"
40
41
#include "mongoc-scram-private.h"
41
42
#include "mongoc-socket.h"
42
43
#include "mongoc-stream-private.h"
@@ -1556,7 +1557,6 @@ _mongoc_cluster_auth_node_sasl (mongoc_cluster_t *cluster,
1556
1557
#endif
1557
1558
1558
1559
1559
- #ifdef MONGOC_ENABLE_SASL
1560
1560
/*
1561
1561
*--------------------------------------------------------------------------
1562
1562
*
@@ -1580,7 +1580,7 @@ _mongoc_cluster_auth_node_plain (mongoc_cluster_t *cluster,
1580
1580
bson_error_t * error )
1581
1581
{
1582
1582
char buf [4096 ];
1583
- unsigned buflen = 0 ;
1583
+ int buflen = 0 ;
1584
1584
bson_iter_t iter ;
1585
1585
const char * username ;
1586
1586
const char * password ;
@@ -1589,7 +1589,6 @@ _mongoc_cluster_auth_node_plain (mongoc_cluster_t *cluster,
1589
1589
bson_t reply ;
1590
1590
size_t len ;
1591
1591
char * str ;
1592
- int ret ;
1593
1592
1594
1593
BSON_ASSERT (cluster );
1595
1594
BSON_ASSERT (node );
@@ -1606,15 +1605,14 @@ _mongoc_cluster_auth_node_plain (mongoc_cluster_t *cluster,
1606
1605
1607
1606
str = bson_strdup_printf ("%c%s%c%s" , '\0' , username , '\0' , password );
1608
1607
len = strlen (username ) + strlen (password ) + 2 ;
1609
- ret = sasl_encode64 ( str , len , buf , sizeof buf , & buflen );
1608
+ buflen = b64_ntop (( const uint8_t * ) str , len , buf , sizeof buf );
1610
1609
bson_free (str );
1611
1610
1612
- if (ret != SASL_OK ) {
1611
+ if (buflen == -1 ) {
1613
1612
bson_set_error (error ,
1614
1613
MONGOC_ERROR_CLIENT ,
1615
1614
MONGOC_ERROR_CLIENT_AUTHENTICATE ,
1616
- "sasl_encode64() returned %d." ,
1617
- ret );
1615
+ "failed base64 encoding message" );
1618
1616
return false;
1619
1617
}
1620
1618
@@ -1648,7 +1646,6 @@ _mongoc_cluster_auth_node_plain (mongoc_cluster_t *cluster,
1648
1646
1649
1647
return true;
1650
1648
}
1651
- #endif
1652
1649
1653
1650
1654
1651
#ifdef MONGOC_ENABLE_SSL
@@ -1875,9 +1872,9 @@ _mongoc_cluster_auth_node (mongoc_cluster_t *cluster,
1875
1872
#ifdef MONGOC_ENABLE_SASL
1876
1873
} else if (0 == strcasecmp (mechanism , "GSSAPI" )) {
1877
1874
ret = _mongoc_cluster_auth_node_sasl (cluster , node , error );
1875
+ #endif
1878
1876
} else if (0 == strcasecmp (mechanism , "PLAIN" )) {
1879
1877
ret = _mongoc_cluster_auth_node_plain (cluster , node , error );
1880
- #endif
1881
1878
} else {
1882
1879
bson_set_error (error ,
1883
1880
MONGOC_ERROR_CLIENT ,
0 commit comments