File tree Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -1664,17 +1664,25 @@ _mongoc_cluster_auth_node_x509 (mongoc_cluster_t *cluster,
1664
1664
BSON_ASSERT (cluster );
1665
1665
BSON_ASSERT (node );
1666
1666
1667
- if (!cluster -> client -> ssl_opts .pem_file ) {
1668
- bson_set_error (error ,
1669
- MONGOC_ERROR_CLIENT ,
1670
- MONGOC_ERROR_CLIENT_AUTHENTICATE ,
1671
- "mongoc_client_set_ssl_opts() must be called "
1672
- "with pem file for X-509 auth." );
1673
- return false;
1674
- }
1667
+ username = mongoc_uri_get_username (cluster -> uri );
1668
+ if (username ) {
1669
+ MONGOC_INFO ("X509: got username (%s) from URI" , username );
1670
+ } else {
1671
+ if (!cluster -> client -> ssl_opts .pem_file ) {
1672
+ bson_set_error (error ,
1673
+ MONGOC_ERROR_CLIENT ,
1674
+ MONGOC_ERROR_CLIENT_AUTHENTICATE ,
1675
+ "cannot determine username "
1676
+ "please either set it as part of the connection string or "
1677
+ "call mongoc_client_set_ssl_opts() "
1678
+ "with pem file for X-509 auth." );
1679
+ return false;
1680
+ }
1675
1681
1676
- if (cluster -> client -> pem_subject ) {
1677
- username = cluster -> client -> pem_subject ;
1682
+ if (cluster -> client -> pem_subject ) {
1683
+ username = cluster -> client -> pem_subject ;
1684
+ MONGOC_INFO ("X509: got username (%s) from certificate" , username );
1685
+ }
1678
1686
}
1679
1687
1680
1688
bson_init (& cmd );
You can’t perform that action at this time.
0 commit comments