@@ -2101,21 +2101,47 @@ _test_mongoc_client_ipv6 (bool pooled)
2101
2101
mongoc_uri_t * uri ;
2102
2102
mongoc_client_pool_t * pool = NULL ;
2103
2103
mongoc_client_t * client ;
2104
+ #if (defined(__APPLE__ ) || defined(_WIN32 )) && defined(MONGOC_ENABLE_SSL )
2105
+ mongoc_ssl_opt_t ssl_opts ;
2106
+ #endif
2104
2107
bson_error_t error ;
2105
2108
2106
2109
uri_str = test_framework_add_user_password_from_env ("mongodb://[::1]/" );
2107
2110
uri = mongoc_uri_new (uri_str );
2108
2111
BSON_ASSERT (uri );
2109
2112
2113
+ #if (defined(__APPLE__ ) || defined(_WIN32 )) && defined(MONGOC_ENABLE_SSL )
2114
+ /* This is necessary because macOS & Windows seem to treat [::1] as not
2115
+ * matching the hostname "0:0:0:0:0:0:0:1", which results in a certificate
2116
+ * trust failure. This behavior has been captured in CDRIVER-3765 (macOS)
2117
+ * and CDRIVER-3766 (Windows). When those are fixed, the code in this
2118
+ * function should be restored to its previous state without the use of
2119
+ * ssl_opts.allow_invalid_hostname. */
2120
+ ssl_opts = * test_framework_get_ssl_opts ();
2121
+ ssl_opts .allow_invalid_hostname = true;
2122
+ #endif
2123
+
2110
2124
if (pooled ) {
2111
2125
pool = mongoc_client_pool_new (uri );
2126
+ #if (defined(__APPLE__ ) || defined(_WIN32 )) && defined(MONGOC_ENABLE_SSL )
2127
+ mongoc_client_pool_set_ssl_opts (pool , & ssl_opts );
2128
+ #else
2112
2129
test_framework_set_pool_ssl_opts (pool );
2130
+ #endif
2113
2131
client = mongoc_client_pool_pop (pool );
2114
2132
} else {
2115
2133
client = mongoc_client_new_from_uri (uri );
2134
+ #if (defined(__APPLE__ ) || defined(_WIN32 )) && defined(MONGOC_ENABLE_SSL )
2135
+ mongoc_client_set_ssl_opts (client , & ssl_opts );
2136
+ #else
2116
2137
test_framework_set_ssl_opts (client );
2138
+ #endif
2117
2139
}
2118
2140
2141
+ #if (defined(__APPLE__ ) || defined(_WIN32 )) && defined(MONGOC_ENABLE_SSL )
2142
+ BSON_ASSERT (client -> ssl_opts .allow_invalid_hostname );
2143
+ #endif
2144
+
2119
2145
ASSERT_OR_PRINT (
2120
2146
mongoc_client_read_command_with_opts (
2121
2147
client , "admin" , tmp_bson ("{'ping': 1}" ), NULL , NULL , NULL , & error ),
0 commit comments