dispatch/server/tls.go

49 lines
1.0 KiB
Go
Raw Normal View History

2016-01-04 18:26:32 +00:00
package server
import (
"crypto/tls"
2016-01-04 18:26:32 +00:00
"os"
"github.com/klauspost/cpuid"
2016-01-04 18:26:32 +00:00
)
func getCipherSuites() []uint16 {
if cpuid.CPU.AesNi() {
return []uint16{
tls.TLS_FALLBACK_SCSV,
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
}
}
return []uint16{
tls.TLS_FALLBACK_SCSV,
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}
}
2018-12-11 09:51:20 +00:00
func (d *Dispatch) certExists() bool {
cfg := d.Config().HTTPS
2016-01-04 18:26:32 +00:00
2018-12-11 09:51:20 +00:00
if cfg.Cert == "" || cfg.Key == "" {
2016-01-04 18:26:32 +00:00
return false
}
2018-12-11 09:51:20 +00:00
if _, err := os.Stat(cfg.Cert); err != nil {
2016-01-04 18:26:32 +00:00
return false
}
2018-12-11 09:51:20 +00:00
if _, err := os.Stat(cfg.Key); err != nil {
2016-01-04 18:26:32 +00:00
return false
}
return true
}