Skip to content

Commit c2c2bd8

Browse files
committed
Provide ability to configure TLSVersion used by the server
1 parent 6e53c69 commit c2c2bd8

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,8 @@ func parseConfig(configFile string) error {
4646
if Config.WriteTimeout == 0 {
4747
Config.WriteTimeout = 300
4848
}
49+
if Config.TLSVersion == "" {
50+
Config.TLSVersion = "tls13"
51+
}
4952
return nil
5053
}

data.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ type Configuration struct {
5555
Scitokens ScitokensConfig `json:"scitokens"` // scitokens configuration
5656
WellKnown string `json:"well_known"` // location of well-known area
5757
Providers []string `json:"providers` // list of JWKS providers
58+
TLSVersion string `json:"tlsVersion"` // minimum TLS version
5859
}
5960

6061
// HTTPRecord provides http record we send to logs endpoint

utils.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,19 @@ func getServer(serverCrt, serverKey string, customVerify bool) (*http.Server, er
9696
log.Fatalf("server loadkeys: %s", err)
9797

9898
}
99+
// see go doc tls.VersionTLS13 for different versions
100+
minVer := tls.VersionTLS13
101+
if Config.TLSVersion == "tls10" {
102+
minVer = tls.VersionTLS10
103+
} else if Config.TLSVersion == "tls11" {
104+
minVer = tls.VersionTLS11
105+
} else if Config.TLSVersion == "tls12" {
106+
minVer = tls.VersionTLS12
107+
} else if Config.TLSVersion == "tls13" {
108+
minVer = tls.VersionTLS13
109+
}
99110
tlsConfig = &tls.Config{
100-
MinVersion: 0x0304,
111+
MinVersion: uint16(minVer),
101112
RootCAs: rootCAs,
102113
Certificates: []tls.Certificate{cert},
103114
}

0 commit comments

Comments
 (0)