@@ -35,6 +35,7 @@ type DocDBConfig struct {
3535 CaFile string `mapstructure:"ca_file"`
3636 ExtraParams string `mapstructure:"extra_params"`
3737 TlsAllowInvalidHostnames bool `mapstructure:"tls_allow_invalid_hostnames"`
38+ TLS bool `mapstructure:"tls"`
3839}
3940
4041// MongoConfig holds target-specific settings
@@ -44,6 +45,7 @@ type MongoConfig struct {
4445 CaFile string `mapstructure:"ca_file"`
4546 ExtraParams string `mapstructure:"extra_params"`
4647 TlsAllowInvalidHostnames bool `mapstructure:"tls_allow_invalid_hostnames"`
48+ TLS bool `mapstructure:"tls"`
4749}
4850
4951// MigrationConfig holds general migration settings
@@ -113,12 +115,14 @@ func LoadConfig() {
113115 viper .SetDefault ("docdb.ca_file" , "global-bundle.pem" )
114116 viper .SetDefault ("docdb.extra_params" , "" )
115117 viper .SetDefault ("docdb.tls_allow_invalid_hostnames" , false )
118+ viper .SetDefault ("docdb.tls" , false )
116119
117120 viper .SetDefault ("mongo.endpoint" , "localhost" )
118121 viper .SetDefault ("mongo.port" , "27017" )
119122 viper .SetDefault ("mongo.ca_file" , "" )
120123 viper .SetDefault ("mongo.extra_params" , "" )
121124 viper .SetDefault ("mongo.tls_allow_invalid_hostnames" , false )
125+ viper .SetDefault ("mongo.tls" , false )
122126
123127 viper .SetDefault ("migration.network_compressors" , "zlib,snappy" )
124128 viper .SetDefault ("migration.exclude_dbs" , []string {"admin" , "local" , "config" })
@@ -220,8 +224,13 @@ func buildTLSParams(extraParams string, allowInvalid bool) string {
220224func (c * Config ) BuildDocDBURI (user , password string ) string {
221225 useTunnel := (c .DocDB .Endpoint == "localhost" || c .DocDB .Endpoint == "127.0.0.1" )
222226 params := url.Values {}
223- addQueryParam (& params , "tls" , "true" )
224- addQueryParam (& params , "tlsCAFile" , c .DocDB .CaFile )
227+ if c .DocDB .TLS {
228+ addQueryParam (& params , "tls" , "true" )
229+ addQueryParam (& params , "tlsCAFile" , c .DocDB .CaFile )
230+ } else {
231+ addQueryParam (& params , "tls" , "false" )
232+ // We do not add tlsCAFile if tls is false
233+ }
225234
226235 if useTunnel {
227236 addQueryParam (& params , "directConnection" , "true" )
@@ -250,10 +259,15 @@ func (c *Config) BuildDocDBURI(user, password string) string {
250259
251260func (c * Config ) BuildMongoURI (user , password string ) string {
252261 params := url.Values {}
253- if c .Mongo .CaFile != "" {
262+ if c .Mongo .TLS {
254263 addQueryParam (& params , "tls" , "true" )
255- addQueryParam (& params , "tlsCAFile" , c .Mongo .CaFile )
264+ if c .Mongo .CaFile != "" {
265+ addQueryParam (& params , "tlsCAFile" , c .Mongo .CaFile )
266+ }
267+ } else {
268+ addQueryParam (& params , "tls" , "false" )
256269 }
270+
257271 addQueryParam (& params , "compressors" , c .Migration .NetworkCompressors )
258272
259273 finalParamsStr := buildTLSParams (c .Mongo .ExtraParams , c .Mongo .TlsAllowInvalidHostnames )
0 commit comments