Skip to content

Commit df484bf

Browse files
alrsccojocar
authored andcommitted
cmd/tlsconfig: remove support for deprecated tls.VersionSSL30 (#412)
* cmd/tlsconfig: build tags to deprecate tls.VersionSSL30 from go1.14 * cmd/tlsconfig: build tags to turn off TLSv1.3 in go1.11
1 parent b4c76d4 commit df484bf

File tree

4 files changed

+93
-24
lines changed

4 files changed

+93
-24
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+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// +build go1.12,!go1.14
2+
3+
// This file can be removed once go1.13 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.3":
17+
versions = append(versions, tls.VersionTLS13)
18+
case "TLSv1.2":
19+
versions = append(versions, tls.VersionTLS12)
20+
case "TLSv1.1":
21+
versions = append(versions, tls.VersionTLS11)
22+
case "TLSv1":
23+
versions = append(versions, tls.VersionTLS10)
24+
case "SSLv3":
25+
// unsupported from go1.14
26+
versions = append(versions, tls.VersionSSL30)
27+
default:
28+
continue
29+
}
30+
}
31+
sort.Ints(versions)
32+
return versions
33+
}

cmd/tlsconfig/tls_version_go14.go

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

cmd/tlsconfig/tlsconfig.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package main
44

55
import (
66
"bytes"
7-
"crypto/tls"
87
"encoding/json"
98
"errors"
109
"flag"
@@ -14,7 +13,6 @@ import (
1413
"log"
1514
"net/http"
1615
"path/filepath"
17-
"sort"
1816
"strings"
1917

2018
"github.com/mozilla/tls-observatory/constants"
@@ -112,28 +110,6 @@ func getGoCipherConfig(name string, sstls ServerSideTLSJson) (goCipherConfigurat
112110
return cipherConf, nil
113111
}
114112

115-
func mapTLSVersions(tlsVersions []string) []int {
116-
var versions []int
117-
for _, tlsVersion := range tlsVersions {
118-
switch tlsVersion {
119-
case "TLSv1.3":
120-
versions = append(versions, tls.VersionTLS13)
121-
case "TLSv1.2":
122-
versions = append(versions, tls.VersionTLS12)
123-
case "TLSv1.1":
124-
versions = append(versions, tls.VersionTLS11)
125-
case "TLSv1":
126-
versions = append(versions, tls.VersionTLS10)
127-
case "SSLv3":
128-
versions = append(versions, tls.VersionSSL30)
129-
default:
130-
continue
131-
}
132-
}
133-
sort.Ints(versions)
134-
return versions
135-
}
136-
137113
func getGoTLSConf() (goTLSConfiguration, error) {
138114
sstls, err := getTLSConfFromURL(TLSConfURL)
139115
if err != nil || sstls == nil {

0 commit comments

Comments
 (0)