Skip to content

Commit de9b608

Browse files
authored
issue #193 - added TLS 1.3 support for Go 1.13 or higher. (#203)
- adds TLS 1.3 and new cipher-suites as config options - remove SSLv3 and the TLS_FALLBACK_SCSV ciphersuite from the sample configuration - removes SSLv3 and the TLS_FALLBACK_SCSV ciphersuite when building with Go 1.14 or above - remove Go 1.10 and Go 1.9 from Travis CI tests, add Go 1.13
1 parent d8ea544 commit de9b608

9 files changed

+47
-17
lines changed

.travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
language: go
22
sudo: false
33
go:
4-
- 1.9
5-
- 1.10.x
64
- 1.11.x
75
- 1.12.x
6+
- 1.13.x
87
- master
98

109
cache:

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ Using Nginx as a proxy
270270

271271
For such purposes as load balancing, terminating TLS early,
272272
or supporting SSL versions not supported by Go (highly not recommended if you
273-
want to use older SSL versions),
273+
want to use older TLS/SSL versions),
274274
it is possible to [use NGINX as a proxy](https://github.com/flashmob/go-guerrilla/wiki/Using-Nginx-as-a-proxy).
275275

276276

config.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,13 @@ type ServerTLSConfig struct {
9898
// https://golang.org/pkg/crypto/tls/#pkg-constants
9999
// Ciphers introduced before Go 1.7 are listed here,
100100
// ciphers since Go 1.8, see tls_go1.8.go
101+
// ....... since Go 1.13, see tls_go1.13.go
101102
var TLSCiphers = map[string]uint16{
102103

103-
// // Note: Generally avoid using CBC unless for compatibility
104+
// Note: Generally avoid using CBC unless for compatibility
105+
// The following ciphersuites are not configurable for TLS 1.3
106+
// see tls_go1.13.go for a list of ciphersuites always used in TLS 1.3
107+
104108
"TLS_RSA_WITH_3DES_EDE_CBC_SHA": tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA,
105109
"TLS_RSA_WITH_AES_128_CBC_SHA": tls.TLS_RSA_WITH_AES_128_CBC_SHA,
106110
"TLS_RSA_WITH_AES_256_CBC_SHA": tls.TLS_RSA_WITH_AES_256_CBC_SHA,
@@ -120,13 +124,12 @@ var TLSCiphers = map[string]uint16{
120124
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384": tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
121125
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384": tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
122126

123-
// Include to prevent downgrade attacks
124-
"TLS_FALLBACK_SCSV": tls.TLS_FALLBACK_SCSV,
127+
// see tls_go1.13 for new TLS 1.3 ciphersuites
128+
// Note that TLS 1.3 ciphersuites are not configurable
125129
}
126130

127131
// https://golang.org/pkg/crypto/tls/#pkg-constants
128132
var TLSProtocols = map[string]uint16{
129-
"ssl3.0": tls.VersionSSL30,
130133
"tls1.0": tls.VersionTLS10,
131134
"tls1.1": tls.VersionTLS11,
132135
"tls1.2": tls.VersionTLS12,
@@ -174,7 +177,7 @@ func (c *AppConfig) Load(jsonBytes []byte) error {
174177
}
175178
}
176179

177-
// read the timestamps for the ssl keys, to determine if they need to be reloaded
180+
// read the timestamps for the TLS keys, to determine if they need to be reloaded
178181
for i := 0; i < len(c.Servers); i++ {
179182
if err := c.Servers[i].loadTlsKeyTimestamps(); err != nil {
180183
return err
@@ -404,7 +407,7 @@ func (sc *ServerConfig) emitChangeEvents(oldServer *ServerConfig, app Guerrilla)
404407
}
405408
}
406409

407-
// Loads in timestamps for the ssl keys
410+
// Loads in timestamps for the TLS keys
408411
func (sc *ServerConfig) loadTlsKeyTimestamps() error {
409412
var statErr = func(iface string, err error) error {
410413
return fmt.Errorf(

goguerrilla.conf.sample

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
"tls_always_on":false,
3232
"private_key_file":"/path/to/pem/file/test.com.key",
3333
"public_key_file":"/path/to/pem/file/test.com.crt",
34-
"protocols" : ["ssl3.0", "tls1.2"],
35-
"ciphers" : ["TLS_FALLBACK_SCSV", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305", "TLS_RSA_WITH_RC4_128_SHA", "TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", "TLS_ECDHE_RSA_WITH_RC4_128_SHA", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"],
34+
"protocols" : ["tls1.0", "tls1.2"],
35+
"ciphers" : ["TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305", "TLS_RSA_WITH_RC4_128_SHA", "TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", "TLS_ECDHE_RSA_WITH_RC4_128_SHA", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"],
3636
"curves" : ["P256", "P384", "P521", "X25519"],
3737
"client_auth_type" : "NoClientCert"
3838
}
@@ -50,8 +50,8 @@
5050
"public_key_file":"/path/to/pem/file/test.com.crt",
5151
"start_tls_on":false,
5252
"tls_always_on":true,
53-
"protocols" : ["ssl3.0", "tls1.2"],
54-
"ciphers" : ["TLS_FALLBACK_SCSV", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305", "TLS_RSA_WITH_RC4_128_SHA", "TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", "TLS_ECDHE_RSA_WITH_RC4_128_SHA", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"],
53+
"protocols" : ["tls1.0", "tls1.2"],
54+
"ciphers" : ["TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305", "TLS_RSA_WITH_RC4_128_SHA", "TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", "TLS_ECDHE_RSA_WITH_RC4_128_SHA", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"],
5555
"curves" : ["P256", "P384", "P521", "X25519"],
5656
"client_auth_type" : "NoClientCert"
5757
}

guerrilla.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ func (g *guerrilla) subscribeEvents() {
320320
// TLS changes
321321
events[EventConfigServerTLSConfig] = serverEvent(func(sc *ServerConfig) {
322322
if server, err := g.findServer(sc.ListenInterface); err == nil {
323-
if err := server.configureSSL(); err == nil {
323+
if err := server.configureTLS(); err == nil {
324324
g.mainlog().Infof("Server [%s] new TLS configuration loaded", sc.ListenInterface)
325325
} else {
326326
g.mainlog().WithError(err).Errorf("Server [%s] failed to load the new TLS configuration", sc.ListenInterface)

server.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ func newServer(sc *ServerConfig, b backends.Backend, mainlog log.Logger) (*serve
113113
}
114114
server.setConfig(sc)
115115
server.setTimeout(sc.Timeout)
116-
if err := server.configureSSL(); err != nil {
116+
if err := server.configureTLS(); err != nil {
117117
return server, err
118118
}
119119
return server, nil
120120
}
121121

122-
func (s *server) configureSSL() error {
122+
func (s *server) configureTLS() error {
123123
sConfig := s.configStore.Load().(ServerConfig)
124124
if sConfig.TLS.AlwaysOn || sConfig.TLS.StartTLSOn {
125125
cert, err := tls.LoadX509KeyPair(sConfig.TLS.PublicKeyFile, sConfig.TLS.PrivateKeyFile)

server_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func TestTLSConfig(t *testing.T) {
222222
Protocols: []string{"tls1.0", "tls1.2"},
223223
},
224224
})
225-
if err := s.configureSSL(); err != nil {
225+
if err := s.configureTLS(); err != nil {
226226
t.Error(err)
227227
}
228228

tls_go1.13.go

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// +build go1.13
2+
3+
package guerrilla
4+
5+
import "crypto/tls"
6+
7+
// TLS 1.3 was introduced in go 1.12 as an option and enabled for production in go 1.13
8+
// release notes: https://golang.org/doc/go1.12#tls_1_3
9+
func init() {
10+
TLSProtocols["tls1.3"] = tls.VersionTLS13
11+
12+
TLSCiphers["TLS_AES_128_GCM_SHA256"] = tls.TLS_AES_128_GCM_SHA256
13+
TLSCiphers["TLS_AES_256_GCM_SHA384"] = tls.TLS_AES_256_GCM_SHA384
14+
TLSCiphers["TLS_CHACHA20_POLY1305_SHA256"] = tls.TLS_CHACHA20_POLY1305_SHA256
15+
}

tls_go1.14.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// +build !go1.14
2+
3+
package guerrilla
4+
5+
import "crypto/tls"
6+
7+
func init() {
8+
9+
TLSProtocols["ssl3.0"] = tls.VersionSSL30 // deprecated since GO 1.13, removed 1.14
10+
11+
// Include to prevent downgrade attacks (SSLv3 only, deprecated in Go 1.13)
12+
TLSCiphers["TLS_FALLBACK_SCSV"] = tls.TLS_FALLBACK_SCSV
13+
}

0 commit comments

Comments
 (0)