Skip to content

Commit 5b0dfb0

Browse files
Wireup allowing insecure ssl
1 parent 79df0d1 commit 5b0dfb0

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

go/base/context.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ type MigrationContext struct {
9494
AliyunRDS bool
9595
GoogleCloudPlatform bool
9696

97-
config ContextConfig
98-
configMutex *sync.Mutex
99-
ConfigFile string
100-
CliUser string
101-
CliPassword string
102-
UseTLS bool
103-
TLSInsecureSkipVerify bool
104-
TLSCACertificate string
105-
CliMasterUser string
106-
CliMasterPassword string
97+
config ContextConfig
98+
configMutex *sync.Mutex
99+
ConfigFile string
100+
CliUser string
101+
CliPassword string
102+
UseTLS bool
103+
TLSAllowInsecure bool
104+
TLSCACertificate string
105+
CliMasterUser string
106+
CliMasterPassword string
107107

108108
HeartbeatIntervalMilliseconds int64
109109
defaultNumRetries int64
@@ -700,7 +700,7 @@ func (this *MigrationContext) ApplyCredentials() {
700700

701701
func (this *MigrationContext) SetupTLS() error {
702702
if this.UseTLS {
703-
return this.InspectorConnectionConfig.UseTLS(this.TLSCACertificate)
703+
return this.InspectorConnectionConfig.UseTLS(this.TLSCACertificate, this.TLSAllowInsecure)
704704
}
705705
return nil
706706
}

go/cmd/gh-ost/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func main() {
5757

5858
flag.BoolVar(&migrationContext.UseTLS, "ssl", false, "Enable SSL encrypted connections to MySQL hosts")
5959
flag.StringVar(&migrationContext.TLSCACertificate, "ssl-ca", "", "CA certificate in PEM format for TLS connections to MySQL hosts. Requires --ssl")
60-
flag.StringVar(&migrationContext.TLSInsecureSkipVerify, "ssl-insecure", false, "Do not verify that the TLS connection is secure. Requires --ssl")
60+
flag.BoolVar(&migrationContext.TLSAllowInsecure, "ssl-allow-insecure", false, "Skips verification of MySQL hosts' certificate chain and host name. Requires --ssl")
6161

6262
flag.StringVar(&migrationContext.DatabaseName, "database", "", "database name (mandatory)")
6363
flag.StringVar(&migrationContext.OriginalTableName, "table", "", "table name (mandatory)")
@@ -202,8 +202,8 @@ func main() {
202202
if migrationContext.TLSCACertificate != "" && !migrationContext.UseTLS {
203203
log.Fatalf("--ssl-ca requires --ssl")
204204
}
205-
if migrationContext.TLSInsecureSkipVerify && !migrationContext.UseTLS {
206-
log.Fatalf("--ssl-insecure requires --ssl")
205+
if migrationContext.TLSAllowInsecure && !migrationContext.UseTLS {
206+
log.Fatalf("--ssl-allow-insecure requires --ssl")
207207
}
208208
if *replicationLagQuery != "" {
209209
log.Warningf("--replication-lag-query is deprecated")

go/mysql/connection.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ func (this *ConnectionConfig) Equals(other *ConnectionConfig) bool {
5757
return this.Key.Equals(&other.Key) || this.ImpliedKey.Equals(other.ImpliedKey)
5858
}
5959

60-
func (this *ConnectionConfig) UseTLS(caCertificatePath string) error {
60+
func (this *ConnectionConfig) UseTLS(caCertificatePath string, allowInsecure bool) error {
6161
var rootCertPool *x509.CertPool
6262
var err error
6363

64-
if !this.TLSInsecureSkipVerify {
64+
if !allowInsecure {
6565
if caCertificatePath == "" {
6666
rootCertPool, err = x509.SystemCertPool()
6767
if err != nil {
@@ -81,7 +81,7 @@ func (this *ConnectionConfig) UseTLS(caCertificatePath string) error {
8181

8282
this.tlsConfig = &tls.Config{
8383
RootCAs: rootCertPool,
84-
InsecureSkipVerify: this.TLSInsecureSkipVerify,
84+
InsecureSkipVerify: allowInsecure,
8585
}
8686

8787
return mysql.RegisterTLSConfig(this.Key.StringCode(), this.tlsConfig)

0 commit comments

Comments
 (0)