Skip to content

Commit

Permalink
update Trillian TLS configuration (#2202)
Browse files Browse the repository at this point in the history
Signed-off-by: Firas Ghanmi <fghanmi@redhat.com>
  • Loading branch information
fghanmi authored Aug 12, 2024
1 parent 25f21f9 commit 542fd11
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/google/trillian"
"github.com/redis/go-redis/v9"
Expand All @@ -49,6 +50,11 @@ import (
)

func dial(rpcServer string) (*grpc.ClientConn, error) {
// Extract the hostname without the port
hostname := rpcServer
if idx := strings.Index(rpcServer, ":"); idx != -1 {
hostname = rpcServer[:idx]
}
// Set up and test connection to rpc server
var creds credentials.TransportCredentials
tlsCACertFile := viper.GetString("trillian_log_server.tls_ca_cert")
Expand All @@ -57,7 +63,7 @@ func dial(rpcServer string) (*grpc.ClientConn, error) {
switch {
case useSystemTrustStore:
creds = credentials.NewTLS(&tls.Config{
ServerName: rpcServer,
ServerName: hostname,
MinVersion: tls.VersionTLS12,
})
case tlsCACertFile != "":
Expand All @@ -70,7 +76,7 @@ func dial(rpcServer string) (*grpc.ClientConn, error) {
return nil, fmt.Errorf("failed to append CA certificate to pool")
}
creds = credentials.NewTLS(&tls.Config{
ServerName: rpcServer,
ServerName: hostname,
RootCAs: certPool,
MinVersion: tls.VersionTLS12,
})
Expand Down

0 comments on commit 542fd11

Please sign in to comment.