Parcourir la source

fix #1611

Allow setting the minimum TLS version
tags/v2.7.0-rc1
Shivaram Lingamneni il y a 3 ans
Parent
révision
1a5d079670
3 fichiers modifiés avec 24 ajouts et 0 suppressions
  1. 2
    0
      default.yaml
  2. 20
    0
      irc/config.go
  3. 2
    0
      traditional.yaml

+ 2
- 0
default.yaml Voir le fichier

@@ -58,6 +58,8 @@ server:
58 58
             # always send a PROXY protocol header ahead of the connection. See the
59 59
             # manual ("Reverse proxies") for more details.
60 60
             proxy: false
61
+            # set the minimum TLS version:
62
+            min-tls-version: 1.2
61 63
 
62 64
         # Example of a Unix domain socket for proxying:
63 65
         # "/tmp/oragono_sock":

+ 20
- 0
irc/config.go Voir le fichier

@@ -59,6 +59,7 @@ type listenerConfigBlock struct {
59 59
 	TLS TLSListenConfig
60 60
 	// SNI configuration, with multiple certificates:
61 61
 	TLSCertificates []TLSListenConfig `yaml:"tls-certificates"`
62
+	MinTLSVersion   string            `yaml:"min-tls-version"`
62 63
 	Proxy           bool
63 64
 	Tor             bool
64 65
 	STSOnly         bool `yaml:"sts-only"`
@@ -881,10 +882,29 @@ func loadTlsConfig(config listenerConfigBlock) (tlsConfig *tls.Config, err error
881 882
 	result := tls.Config{
882 883
 		Certificates: certificates,
883 884
 		ClientAuth:   clientAuth,
885
+		MinVersion:   tlsMinVersionFromString(config.MinTLSVersion),
884 886
 	}
885 887
 	return &result, nil
886 888
 }
887 889
 
890
+func tlsMinVersionFromString(version string) uint16 {
891
+	version = strings.ToLower(version)
892
+	version = strings.TrimPrefix(version, "v")
893
+	switch version {
894
+	case "1", "1.0":
895
+		return tls.VersionTLS10
896
+	case "1.1":
897
+		return tls.VersionTLS11
898
+	case "1.2":
899
+		return tls.VersionTLS12
900
+	case "1.3":
901
+		return tls.VersionTLS13
902
+	default:
903
+		// tls package will fill in a sane value, currently 1.0
904
+		return 0
905
+	}
906
+}
907
+
888 908
 func loadCertWithLeaf(certFile, keyFile string) (cert tls.Certificate, err error) {
889 909
 	// LoadX509KeyPair: "On successful return, Certificate.Leaf will be nil because
890 910
 	// the parsed form of the certificate is not retained." tls.Config:

+ 2
- 0
traditional.yaml Voir le fichier

@@ -32,6 +32,8 @@ server:
32 32
             # always send a PROXY protocol header ahead of the connection. See the
33 33
             # manual ("Reverse proxies") for more details.
34 34
             proxy: false
35
+            # optionally set the minimum TLS version (defaults to 1.0):
36
+            # min-tls-version: 1.2
35 37
 
36 38
         # Example of a Unix domain socket for proxying:
37 39
         # "/tmp/oragono_sock":

Chargement…
Annuler
Enregistrer