-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add support for custom tls.Configs #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
481dc97
4974720
b18f20a
17ee918
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package mysql | ||
|
||
import ( | ||
"crypto/tls" | ||
) | ||
|
||
type TLSConfig interface { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this interface for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed, as you commented on later. |
||
SetTLSConfig(key string, config *tls.Config) | ||
} | ||
|
||
var tlsConfigMap = make(map[string]*tls.Config) | ||
|
||
func (d *mysqlDriver) SetTLSConfig(key string, config *tls.Config) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Four things here: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. Will do. |
||
tlsConfigMap[key] = config | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,6 +152,9 @@ func parseDSN(dsn string) (cfg *config, err error) { | |
cfg.tls = &tls.Config{} | ||
} else if strings.ToLower(value) == "skip-verify" { | ||
cfg.tls = &tls.Config{InsecureSkipVerify: true} | ||
} else if tlsConfig, ok := tlsConfigMap[value]; ok { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you want this done in a different way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My plan is to edit the readBool function / introduce another function which reports if the input was a valid bool representation (so also checks if the input was |
||
cfg.tls = &tls.Config{} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this line is necessary (but I haven't tested it). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How else would you be able to do "tls=customkey" in the DSN? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant L156, the "zeroing". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, got ya. Yeah, I'll change that as well. |
||
*cfg.tls = *tlsConfig | ||
} | ||
|
||
default: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The total number of lines in this file is really small. I don't think this is worth its own file. Please move it to a section in utils.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.