@@ -134,6 +134,12 @@ func startAction(cmd *cobra.Command, args []string) {
134134
135135 logging .PrintStep ("Connecting to source DocumentDB..." , 0 )
136136 clientOpts := options .Client ().ApplyURI (docdbURI )
137+ // --- Conditionally apply InsecureSkipVerify ---
138+ // If TLS is ON and we need to skip hostname validation (e.g. tunneling),
139+ // we must force the driver to use a custom TLS config.
140+ if config .Cfg .DocDB .TLS && config .Cfg .DocDB .TlsAllowInvalidHostnames {
141+ clientOpts .SetTLSConfig (& tls.Config {InsecureSkipVerify : true })
142+ }
137143 sourceClient , err := mongo .Connect (clientOpts )
138144 if err != nil {
139145 logging .PrintError (fmt .Sprintf ("Failed to create source client: %v" , err ), 0 )
@@ -149,6 +155,13 @@ func startAction(cmd *cobra.Command, args []string) {
149155
150156 logging .PrintStep ("Connecting to target MongoDB..." , 0 )
151157 mongoClientOpts := options .Client ().ApplyURI (mongoURI )
158+ // --- Conditionally apply InsecureSkipVerify ---
159+ // If TLS is ON and we need to skip hostname validation (e.g. tunneling),
160+ // we must force the driver to use a custom TLS config.
161+ if config .Cfg .Mongo .TLS && config .Cfg .Mongo .TlsAllowInvalidHostnames {
162+ mongoClientOpts .SetTLSConfig (& tls.Config {InsecureSkipVerify : true })
163+ }
164+
152165 targetClient , err := mongo .Connect (mongoClientOpts )
153166 if err != nil {
154167 logging .PrintError (fmt .Sprintf ("Failed to create target client: %v" , err ), 0 )
0 commit comments