@@ -150,7 +150,7 @@ static int32_t
150
150
_int32_from_le (const void * data )
151
151
{
152
152
BSON_ASSERT_PARAM (data );
153
- return bson_iter_int32_unsafe (& (bson_iter_t ){.raw = data });
153
+ return bson_iter_int32_unsafe (& (bson_iter_t ) {.raw = data });
154
154
}
155
155
156
156
@@ -813,12 +813,7 @@ _stream_run_hello (mongoc_cluster_t *cluster,
813
813
_mongoc_topology_dup_handshake_cmd (cluster -> client -> topology , & handshake_command );
814
814
815
815
if (cluster -> requires_auth && speculative_auth_response ) {
816
- mongoc_ssl_opt_t * ssl_opts = NULL ;
817
- #ifdef MONGOC_ENABLE_SSL
818
- ssl_opts = & cluster -> client -> ssl_opts ;
819
- #endif
820
-
821
- _mongoc_topology_scanner_add_speculative_authentication (& handshake_command , cluster -> uri , ssl_opts , scram );
816
+ _mongoc_topology_scanner_add_speculative_authentication (& handshake_command , cluster -> uri , scram );
822
817
}
823
818
824
819
if (negotiate_sasl_supported_mechs ) {
@@ -1059,10 +1054,7 @@ _mongoc_cluster_auth_node_plain (mongoc_cluster_t *cluster,
1059
1054
}
1060
1055
1061
1056
bool
1062
- _mongoc_cluster_get_auth_cmd_x509 (const mongoc_uri_t * uri ,
1063
- const mongoc_ssl_opt_t * ssl_opts ,
1064
- bson_t * cmd /* OUT */ ,
1065
- bson_error_t * error /* OUT */ )
1057
+ _mongoc_cluster_get_auth_cmd_x509 (const mongoc_uri_t * uri , bson_t * cmd /* OUT */ , bson_error_t * error /* OUT */ )
1066
1058
{
1067
1059
#ifndef MONGOC_ENABLE_SSL
1068
1060
bson_set_error (error ,
@@ -1073,41 +1065,21 @@ _mongoc_cluster_get_auth_cmd_x509 (const mongoc_uri_t *uri,
1073
1065
return false;
1074
1066
#else
1075
1067
const char * username_from_uri = NULL ;
1076
- char * username_from_subject = NULL ;
1077
1068
1078
1069
BSON_ASSERT (uri );
1070
+ BSON_UNUSED (error );
1079
1071
1080
1072
username_from_uri = mongoc_uri_get_username (uri );
1081
1073
if (username_from_uri ) {
1082
1074
TRACE ("%s" , "X509: got username from URI" );
1083
- } else {
1084
- if (!ssl_opts || !ssl_opts -> pem_file ) {
1085
- bson_set_error (error ,
1086
- MONGOC_ERROR_CLIENT ,
1087
- MONGOC_ERROR_CLIENT_AUTHENTICATE ,
1088
- "cannot determine username for "
1089
- "X-509 authentication." );
1090
- return false;
1091
- }
1092
-
1093
- username_from_subject = mongoc_ssl_extract_subject (ssl_opts -> pem_file , ssl_opts -> pem_pwd );
1094
- if (!username_from_subject ) {
1095
- bson_set_error (error ,
1096
- MONGOC_ERROR_CLIENT ,
1097
- MONGOC_ERROR_CLIENT_AUTHENTICATE ,
1098
- "No username provided for X509 authentication." );
1099
- return false;
1100
- }
1101
-
1102
- TRACE ("%s" , "X509: got username from certificate" );
1103
1075
}
1104
1076
1105
1077
bson_init (cmd );
1106
1078
BSON_APPEND_INT32 (cmd , "authenticate" , 1 );
1107
1079
BSON_APPEND_UTF8 (cmd , "mechanism" , "MONGODB-X509" );
1108
- BSON_APPEND_UTF8 ( cmd , "user" , username_from_uri ? username_from_uri : username_from_subject );
1109
-
1110
- bson_free ( username_from_subject );
1080
+ if ( username_from_uri ) {
1081
+ BSON_APPEND_UTF8 ( cmd , "user" , username_from_uri );
1082
+ }
1111
1083
1112
1084
return true;
1113
1085
#endif
@@ -1138,7 +1110,7 @@ _mongoc_cluster_auth_node_x509 (mongoc_cluster_t *cluster,
1138
1110
BSON_ASSERT (cluster );
1139
1111
BSON_ASSERT (stream );
1140
1112
1141
- if (!_mongoc_cluster_get_auth_cmd_x509 (cluster -> uri , & cluster -> client -> ssl_opts , & cmd , error )) {
1113
+ if (!_mongoc_cluster_get_auth_cmd_x509 (cluster -> uri , & cmd , error )) {
1142
1114
return false;
1143
1115
}
1144
1116
0 commit comments