-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
support tls 1.3 #7325
support tls 1.3 #7325
Changes from 1 commit
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 |
---|---|---|
|
@@ -30,8 +30,12 @@ var TLSLookup = map[string]uint16{ | |
"tls10": tls.VersionTLS10, | ||
"tls11": tls.VersionTLS11, | ||
"tls12": tls.VersionTLS12, | ||
"tls13": tls.VersionTLS13, | ||
} | ||
|
||
// TLSVersions has all the keys from the map above, make sure to keep both in sync | ||
var TLSVersions = "tls10, tls11, tls12, tls13" | ||
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 didn't want to have a function iterating over the keys again and again. And then I had a var with 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. And I think it is better now because both vars are colocated and it is easier to spot the dependency than before. 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.
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. That should do a one time generation of the string. But like I said, it doesn't really matter. I doubt there will be a tls 1.4 any time soon. Its sort of like the copyright thing. You might change it once a year so is it worth keeping the code around rather than just updating it very rarely? |
||
|
||
// Config used to create tls.Config | ||
type Config struct { | ||
// VerifyIncoming is used to verify the authenticity of incoming | ||
|
@@ -323,7 +327,7 @@ func (c *Configurator) check(config Config, pool *x509.CertPool, cert *tls.Certi | |
// Check if a minimum TLS version was set | ||
if config.TLSMinVersion != "" { | ||
if _, ok := TLSLookup[config.TLSMinVersion]; !ok { | ||
return fmt.Errorf("TLSMinVersion: value %s not supported, please specify one of [tls10,tls11,tls12]", config.TLSMinVersion) | ||
return fmt.Errorf("TLSMinVersion: value %s not supported, please specify one of [%s]", config.TLSMinVersion, TLSVersions) | ||
} | ||
} | ||
|
||
|
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.
Couldn't we instead use an
init
func and programmatically generate this?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.
Good catch! I went with a normal function instead. But the idea is the same.