@@ -546,10 +546,14 @@ func runMigrationProcess(cmd *cobra.Command, args []string) {
546546
547547 docdbURI := config .Cfg .BuildDocDBURI (docdbUser , docdbPass )
548548 mongoURI := config .Cfg .BuildMongoURI (mongoUser , mongoPass )
549- tlsConfig := & tls.Config {InsecureSkipVerify : config .Cfg .DocDB .TlsAllowInvalidHostnames }
550- clientOpts := options .Client ().ApplyURI (docdbURI ).SetTLSConfig (tlsConfig )
551549
550+ // --- Use conditional TLS logic for Source (DocumentDB) ---
551+ clientOpts := options .Client ().ApplyURI (docdbURI )
552+ if config .Cfg .DocDB .TLS && config .Cfg .DocDB .TlsAllowInvalidHostnames {
553+ clientOpts .SetTLSConfig (& tls.Config {InsecureSkipVerify : true })
554+ }
552555 sourceClient , err := mongo .Connect (clientOpts )
556+
553557 if err != nil {
554558 logging .PrintError (err .Error (), 0 )
555559 return
@@ -563,9 +567,13 @@ func runMigrationProcess(cmd *cobra.Command, args []string) {
563567 }
564568 }()
565569
566- mongoTlsConfig := & tls.Config {InsecureSkipVerify : config .Cfg .Mongo .TlsAllowInvalidHostnames }
567- mongoClientOpts := options .Client ().ApplyURI (mongoURI ).SetTLSConfig (mongoTlsConfig )
570+ // --- Use conditional TLS logic for Target (MongoDB) ---
571+ mongoClientOpts := options .Client ().ApplyURI (mongoURI )
572+ if config .Cfg .Mongo .TLS && config .Cfg .Mongo .TlsAllowInvalidHostnames {
573+ mongoClientOpts .SetTLSConfig (& tls.Config {InsecureSkipVerify : true })
574+ }
568575 targetClient , err := mongo .Connect (mongoClientOpts )
576+
569577 if err != nil {
570578 logging .PrintError (err .Error (), 0 )
571579 return
@@ -872,7 +880,7 @@ func init() {
872880 runCmd .Flags ().String ("docdb-pass" , "" , "" )
873881 runCmd .Flags ().String ("mongo-pass" , "" , "" )
874882 runCmd .Flags ().Bool ("destroy" , false , "" )
875- runCmd .Flags ().Bool ("debug" , false , "" ) // Internal debug flag for run command
883+ runCmd .Flags ().Bool ("debug" , false , "" )
876884 runCmd .Flags ().MarkHidden ("docdb-user" )
877885 runCmd .Flags ().MarkHidden ("mongo-user" )
878886 runCmd .Flags ().MarkHidden ("docdb-pass" )
0 commit comments