Skip to content

Commit c02bc17

Browse files
committed
cmd/tlsconfig: build tags to turn off TLSv1.3 in go1.11
1 parent d459bb8 commit c02bc17

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

cmd/tlsconfig/tls_version_go11.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// +build !go1.12
2+
3+
// This file can be removed once go1.11 is no longer supported
4+
5+
package main
6+
7+
import (
8+
"crypto/tls"
9+
"sort"
10+
)
11+
12+
func mapTLSVersions(tlsVersions []string) []int {
13+
var versions []int
14+
for _, tlsVersion := range tlsVersions {
15+
switch tlsVersion {
16+
case "TLSv1.2":
17+
versions = append(versions, tls.VersionTLS12)
18+
case "TLSv1.1":
19+
versions = append(versions, tls.VersionTLS11)
20+
case "TLSv1":
21+
versions = append(versions, tls.VersionTLS10)
22+
case "SSLv3":
23+
// unsupported from go1.14
24+
versions = append(versions, tls.VersionSSL30)
25+
default:
26+
continue
27+
}
28+
}
29+
sort.Ints(versions)
30+
return versions
31+
}

cmd/tlsconfig/tls_version_deprecated.go renamed to cmd/tlsconfig/tls_version_go12_go13.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build !go1.14
1+
// +build go1.12,!go1.14
22

33
// This file can be removed once go1.13 is no longer supported
44

cmd/tlsconfig/tls_version_future.go renamed to cmd/tlsconfig/tls_version_go14.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build go1.14
1+
// +build go1.14 !go1.11
22

33
// main
44
package main

0 commit comments

Comments
 (0)