@@ -804,12 +804,7 @@ _stream_run_hello (mongoc_cluster_t *cluster,
804
804
_mongoc_topology_dup_handshake_cmd (cluster -> client -> topology , & handshake_command );
805
805
806
806
if (cluster -> requires_auth && speculative_auth_response ) {
807
- mongoc_ssl_opt_t * ssl_opts = NULL ;
808
- #ifdef MONGOC_ENABLE_SSL
809
- ssl_opts = & cluster -> client -> ssl_opts ;
810
- #endif
811
-
812
- _mongoc_topology_scanner_add_speculative_authentication (& handshake_command , cluster -> uri , ssl_opts , scram );
807
+ _mongoc_topology_scanner_add_speculative_authentication (& handshake_command , cluster -> uri , scram );
813
808
}
814
809
815
810
if (negotiate_sasl_supported_mechs ) {
@@ -1053,10 +1048,7 @@ _mongoc_cluster_auth_node_plain (mongoc_cluster_t *cluster,
1053
1048
}
1054
1049
1055
1050
bool
1056
- _mongoc_cluster_get_auth_cmd_x509 (const mongoc_uri_t * uri ,
1057
- const mongoc_ssl_opt_t * ssl_opts ,
1058
- bson_t * cmd /* OUT */ ,
1059
- bson_error_t * error /* OUT */ )
1051
+ _mongoc_cluster_get_auth_cmd_x509 (const mongoc_uri_t * uri , bson_t * cmd /* OUT */ , bson_error_t * error /* OUT */ )
1060
1052
{
1061
1053
#ifndef MONGOC_ENABLE_SSL
1062
1054
_mongoc_set_error (error ,
@@ -1067,41 +1059,21 @@ _mongoc_cluster_get_auth_cmd_x509 (const mongoc_uri_t *uri,
1067
1059
return false;
1068
1060
#else
1069
1061
const char * username_from_uri = NULL ;
1070
- char * username_from_subject = NULL ;
1071
1062
1072
1063
BSON_ASSERT (uri );
1064
+ BSON_UNUSED (error );
1073
1065
1074
1066
username_from_uri = mongoc_uri_get_username (uri );
1075
1067
if (username_from_uri ) {
1076
1068
TRACE ("%s" , "X509: got username from URI" );
1077
- } else {
1078
- if (!ssl_opts || !ssl_opts -> pem_file ) {
1079
- _mongoc_set_error (error ,
1080
- MONGOC_ERROR_CLIENT ,
1081
- MONGOC_ERROR_CLIENT_AUTHENTICATE ,
1082
- "cannot determine username for "
1083
- "X-509 authentication." );
1084
- return false;
1085
- }
1086
-
1087
- username_from_subject = mongoc_ssl_extract_subject (ssl_opts -> pem_file , ssl_opts -> pem_pwd );
1088
- if (!username_from_subject ) {
1089
- _mongoc_set_error (error ,
1090
- MONGOC_ERROR_CLIENT ,
1091
- MONGOC_ERROR_CLIENT_AUTHENTICATE ,
1092
- "No username provided for X509 authentication." );
1093
- return false;
1094
- }
1095
-
1096
- TRACE ("%s" , "X509: got username from certificate" );
1097
1069
}
1098
1070
1099
1071
bson_init (cmd );
1100
1072
BSON_APPEND_INT32 (cmd , "authenticate" , 1 );
1101
1073
BSON_APPEND_UTF8 (cmd , "mechanism" , "MONGODB-X509" );
1102
- BSON_APPEND_UTF8 ( cmd , "user" , username_from_uri ? username_from_uri : username_from_subject );
1103
-
1104
- bson_free ( username_from_subject );
1074
+ if ( username_from_uri ) {
1075
+ BSON_APPEND_UTF8 ( cmd , "user" , username_from_uri );
1076
+ }
1105
1077
1106
1078
return true;
1107
1079
#endif
@@ -1132,7 +1104,7 @@ _mongoc_cluster_auth_node_x509 (mongoc_cluster_t *cluster,
1132
1104
BSON_ASSERT (cluster );
1133
1105
BSON_ASSERT (stream );
1134
1106
1135
- if (!_mongoc_cluster_get_auth_cmd_x509 (cluster -> uri , & cluster -> client -> ssl_opts , & cmd , error )) {
1107
+ if (!_mongoc_cluster_get_auth_cmd_x509 (cluster -> uri , & cmd , error )) {
1136
1108
return false;
1137
1109
}
1138
1110
0 commit comments