URI options may be passed to a mongoc_uri_t in three ways.
1. Through the string passed to the mongoc_uri_new call.
uri = mongoc_uri_new ("mongodb://localhost:27017/?ssl=true");
2. After creation, through the mongoc_uri_set_option_as_* helpers
uri = mongoc_uri_new ("mongodb://localhost:27017/"); mongoc_uri_set_option_as_bool (uri, "ssl", false);
3. Via TXT records on a mongodb+srv URI.
mongoc_uri_parse_options validates that there are no conflicts between canonical and non-canonical values (e.g. having both ssl=true and tls=false). It is called for both (1) and (3).
mongoc_uri_finalize_tls, mongoc_uri_finalize_auth, mongoc_uri_finalize_directconnection validate other state of URI options. It is only called for (1).
Options set by (2) may not undergo validation unless they validated from options being applied by (3).
URI options should be validated regardless of how options are set. The proposed solution is to validate URI options on client/client pool construction by introducing the new APIs:
mongoc_client_t* mongoc_client_new_with_error (mongoc_uri_t* uri, bson_error_t* error); mongoc_client_pool_t* mongoc_client_pool_new_with_error (mongoc_uri_t* uri, bson_error_t* error);
- is depended on by
-
CDRIVER-4253 Use with_error client and pool constructors in test suite
- Backlog
-
CDRIVER-4254 Prohibit construction of invalid topology in mongoc_topology_new
- Backlog
-
PHPC-1647 Defer to libmongoc for cross-option URI validation
- Closed
-
CDRIVER-4255 Add assertions for non-null client and pool parameters
- Closed
- is duplicated by
-
CDRIVER-4254 Prohibit construction of invalid topology in mongoc_topology_new
- Backlog
- is related to
-
CDRIVER-3476 Lowercase options before storing when set via mongoc_uri_set_option_as_*
- Closed
- related to
-
CDRIVER-4251 mongoc_client_new_from_uri may leak topology
- Closed
-
CDRIVER-4250 Create public API to expose mongoc_uri_finalize functions
- Closed
-
PHPC-1950 Lift restriction on authSource without credentials when set in URI options array
- Closed