Skip to content

Commit 3e1e4ad

Browse files
committed
[FAB-4848] Only allow TLS 1.2
Prior to this change, it was possible to use TLS version < 1.2 to connect to gRPC endpoints. This change sets the min/max TLS version to 1.2 for the common gRPC server used by all production gRPC endpoints. It does not change the min version for the various generic gRPC servers used in other tests. Change-Id: Ibf34777976551d12861599fb5ef37a93b07ece95 Signed-off-by: Gari Singh <[email protected]>
1 parent feded5a commit 3e1e4ad

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

core/comm/creds.go

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ func NewServerTransportCredentials(serverConfig *tls.Config) credentials.Transpo
3333
// NOTE: unlike the default grpc/credentials implementation, we do not
3434
// clone the tls.Config which allows us to update it dynamically
3535
serverConfig.NextProtos = alpnProtoStr
36+
// override TLS version and ensure it is 1.2
37+
serverConfig.MinVersion = tls.VersionTLS12
38+
serverConfig.MaxVersion = tls.VersionTLS12
3639
return &serverCreds{serverConfig}
3740
}
3841

core/comm/server_test.go

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
/*
2-
Copyright IBM Corp. 2016 All Rights Reserved.
2+
Copyright IBM Corp. All Rights Reserved.
33
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
4+
SPDX-License-Identifier: Apache-2.0
155
*/
166

177
package comm_test
@@ -641,6 +631,20 @@ func TestNewSecureGRPCServer(t *testing.T) {
641631
} else {
642632
t.Log("GRPC client successfully invoked the EmptyCall service: " + testAddress)
643633
}
634+
635+
// ensure that TLS 1.2 in required / enforced
636+
for _, tlsVersion := range []uint16{tls.VersionSSL30, tls.VersionTLS10, tls.VersionTLS11} {
637+
_, err = invokeEmptyCall(testAddress,
638+
[]grpc.DialOption{grpc.WithTransportCredentials(
639+
credentials.NewTLS(&tls.Config{
640+
RootCAs: certPool,
641+
MinVersion: tlsVersion,
642+
MaxVersion: tlsVersion,
643+
}))})
644+
t.Logf("TLSVersion [%d] failed with [%s]", tlsVersion, err)
645+
assert.Error(t, err, "Should not have been able to connect with TLS version < 1.2")
646+
assert.Contains(t, err.Error(), "protocol version not supported")
647+
}
644648
}
645649

646650
func TestNewSecureGRPCServerFromListener(t *testing.T) {

0 commit comments

Comments
 (0)