Pārlūkot izejas kodu

fix #1611

Allow setting the minimum TLS version
tags/v2.7.0-rc1
Shivaram Lingamneni 3 gadus atpakaļ
vecāks
revīzija
1a5d079670
3 mainītis faili ar 24 papildinājumiem un 0 dzēšanām
  1. 2
    0
      default.yaml
  2. 20
    0
      irc/config.go
  3. 2
    0
      traditional.yaml

+ 2
- 0
default.yaml Parādīt failu

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

+ 20
- 0
irc/config.go Parādīt failu

59
 	TLS TLSListenConfig
59
 	TLS TLSListenConfig
60
 	// SNI configuration, with multiple certificates:
60
 	// SNI configuration, with multiple certificates:
61
 	TLSCertificates []TLSListenConfig `yaml:"tls-certificates"`
61
 	TLSCertificates []TLSListenConfig `yaml:"tls-certificates"`
62
+	MinTLSVersion   string            `yaml:"min-tls-version"`
62
 	Proxy           bool
63
 	Proxy           bool
63
 	Tor             bool
64
 	Tor             bool
64
 	STSOnly         bool `yaml:"sts-only"`
65
 	STSOnly         bool `yaml:"sts-only"`
881
 	result := tls.Config{
882
 	result := tls.Config{
882
 		Certificates: certificates,
883
 		Certificates: certificates,
883
 		ClientAuth:   clientAuth,
884
 		ClientAuth:   clientAuth,
885
+		MinVersion:   tlsMinVersionFromString(config.MinTLSVersion),
884
 	}
886
 	}
885
 	return &result, nil
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
 func loadCertWithLeaf(certFile, keyFile string) (cert tls.Certificate, err error) {
908
 func loadCertWithLeaf(certFile, keyFile string) (cert tls.Certificate, err error) {
889
 	// LoadX509KeyPair: "On successful return, Certificate.Leaf will be nil because
909
 	// LoadX509KeyPair: "On successful return, Certificate.Leaf will be nil because
890
 	// the parsed form of the certificate is not retained." tls.Config:
910
 	// the parsed form of the certificate is not retained." tls.Config:

+ 2
- 0
traditional.yaml Parādīt failu

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

Notiek ielāde…
Atcelt
Saglabāt