Skip to content

Commit 9f74ab8

Browse files
committed
Make ssl.conf a Go template with overridable cipher suite and protocol
Signed-off-by: Francesco Pantano <fpantano@redhat.com>
1 parent 7ebfadd commit 9f74ab8

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

modules/common/util/template_util_test.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,14 +680,29 @@ baz=1
680680
}
681681

682682
func TestGetCommonTemplates(t *testing.T) {
683-
t.Run("Returns ssl.conf", func(t *testing.T) {
683+
t.Run("Returns ssl.conf with defaults", func(t *testing.T) {
684684
g := NewWithT(t)
685685

686686
result, err := GetCommonTemplates(map[string]interface{}{})
687687
g.Expect(err).NotTo(HaveOccurred())
688688
g.Expect(result).To(HaveKey("ssl.conf"))
689689
g.Expect(result["ssl.conf"]).To(ContainSubstring("mod_ssl"))
690-
g.Expect(result["ssl.conf"]).To(ContainSubstring("SSLProtocol"))
691-
g.Expect(result["ssl.conf"]).To(ContainSubstring("SSLCipherSuite"))
690+
g.Expect(result["ssl.conf"]).To(ContainSubstring("SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!RC4:!3DES"))
691+
g.Expect(result["ssl.conf"]).To(ContainSubstring("SSLProtocol all -SSLv2 -SSLv3 -TLSv1"))
692+
})
693+
694+
t.Run("SSLCipherSuite and SSLProtocol can be overridden", func(t *testing.T) {
695+
g := NewWithT(t)
696+
697+
result, err := GetCommonTemplates(map[string]interface{}{
698+
"SSLCipherSuite": "ECDHE+AESGCM:ECDHE+CHACHA20",
699+
"SSLProtocol": "-all +TLSv1.3",
700+
})
701+
g.Expect(err).NotTo(HaveOccurred())
702+
g.Expect(result).To(HaveKey("ssl.conf"))
703+
g.Expect(result["ssl.conf"]).To(ContainSubstring("SSLCipherSuite ECDHE+AESGCM:ECDHE+CHACHA20"))
704+
g.Expect(result["ssl.conf"]).To(ContainSubstring("SSLProtocol -all +TLSv1.3"))
705+
g.Expect(result["ssl.conf"]).NotTo(ContainSubstring("HIGH:MEDIUM"))
706+
g.Expect(result["ssl.conf"]).NotTo(ContainSubstring("all -SSLv2"))
692707
})
693708
}

modules/common/util/templates/common/config/ssl.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
SSLHonorCipherOrder On
1616
SSLUseStapling Off
1717
SSLStaplingCache "shmcb:/run/httpd/ssl_stapling(32768)"
18-
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!RC4:!3DES
19-
SSLProtocol all -SSLv2 -SSLv3 -TLSv1
18+
SSLCipherSuite {{ or (index . "SSLCipherSuite") "HIGH:MEDIUM:!aNULL:!MD5:!RC4:!3DES" }}
19+
SSLProtocol {{ or (index . "SSLProtocol") "all -SSLv2 -SSLv3 -TLSv1" }}
2020
SSLOptions StdEnvVars
2121
</IfModule>

0 commit comments

Comments
 (0)