Skip to content

Commit 79c26b4

Browse files
authored
feat(fips): bump supported min tls version to 1.2 (#286)
bump supported min tls version to 1.2 The default min version is still tls1.2 but 1.1 shouldn't be supported in fips mode even if explicitly configured since it won't be available
1 parent dec2158 commit 79c26b4

File tree

4 files changed

+75
-3
lines changed

4 files changed

+75
-3
lines changed

transport/tlscommon/versions_default.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ const (
3030
)
3131

3232
var (
33-
// TLSVersionMin is the min TLS version supported.
34-
TLSVersionMin = TLSVersion11
35-
3633
// TLSVersionMax is the max TLS version supported.
3734
TLSVersionMax = TLSVersion13
3835

transport/tlscommon/versions_fips.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919

2020
package tlscommon
2121

22+
var (
23+
// TLSVersionMin is the min TLS version supported.
24+
TLSVersionMin = TLSVersion12
25+
)
26+
2227
func SetInsecureDefaults() {
2328
// noop, use secure defaults in fips
2429
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Licensed to Elasticsearch B.V. under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. Elasticsearch B.V. licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
//go:build requirefips
19+
20+
package tlscommon
21+
22+
import (
23+
"crypto/tls"
24+
"testing"
25+
26+
"github.com/stretchr/testify/require"
27+
)
28+
29+
func TestFIPSTLSVersion(t *testing.T) {
30+
// These tests are a bit verbose, but given the sensitivity to changes here, it's not a bad idea.
31+
tests := []struct {
32+
name string
33+
v uint16
34+
expectErr string
35+
}{
36+
{
37+
name: "TLSv1.0",
38+
v: tls.VersionTLS10,
39+
expectErr: "unsupported tls version: TLSv1.0",
40+
},
41+
{
42+
name: "TLSv1.1",
43+
v: tls.VersionTLS11,
44+
expectErr: "unsupported tls version: TLSv1.1",
45+
},
46+
{
47+
name: "TLSv1.2",
48+
v: tls.VersionTLS12,
49+
},
50+
{
51+
name: "TLSv1.3",
52+
v: tls.VersionTLS13,
53+
},
54+
}
55+
for _, tt := range tests {
56+
t.Run(tt.name, func(t *testing.T) {
57+
tv := TLSVersion(tt.v)
58+
if tt.expectErr != "" {
59+
require.EqualError(t, tv.Validate(), tt.expectErr)
60+
} else {
61+
require.NoError(t, tv.Validate())
62+
}
63+
})
64+
}
65+
}

transport/tlscommon/versions_nofips.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919

2020
package tlscommon
2121

22+
var (
23+
// TLSVersionMin is the min TLS version supported.
24+
TLSVersionMin = TLSVersion11
25+
)
26+
2227
// This function is used to avoid a breaking change on previous releases.
2328
func SetInsecureDefaults() {
2429
TLSVersionMin = TLSVersion10

0 commit comments

Comments
 (0)