TLS: allow to configure cipher suites

Fixes #316
This commit is contained in:
Nicola Murino
2021-02-18 20:17:16 +01:00
parent 82b26f81d6
commit 5d3288c37d
12 changed files with 162 additions and 19 deletions

View File

@@ -9,6 +9,7 @@ import (
"crypto/elliptic"
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"encoding/hex"
"encoding/pem"
@@ -436,3 +437,18 @@ func HTTPListenAndServe(srv *http.Server, address string, port int, isTLS bool,
}
return srv.Serve(listener)
}
// GetTLSCiphersFromNames returns the TLS ciphers from the specified names
func GetTLSCiphersFromNames(cipherNames []string) []uint16 {
var ciphers []uint16
for _, name := range RemoveDuplicates(cipherNames) {
for _, c := range tls.CipherSuites() {
if c.Name == strings.TrimSpace(name) {
ciphers = append(ciphers, c.ID)
}
}
}
return ciphers
}