2020-04-27 22:26:15 +00:00
|
|
|
package config
|
|
|
|
|
2020-06-24 10:25:34 +00:00
|
|
|
import (
|
|
|
|
"crypto/tls"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
)
|
2020-04-27 22:26:15 +00:00
|
|
|
|
|
|
|
type CurveType string
|
|
|
|
|
2020-06-24 10:25:34 +00:00
|
|
|
type TLSVersion string
|
|
|
|
|
|
|
|
func (x TLSVersion) Value() string {
|
|
|
|
return strings.ToUpper(string(x))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x TLSVersion) TLSVersion() uint16 {
|
|
|
|
switch TLSVersion(x.Value()) {
|
|
|
|
case TLSVersionSSL3:
|
|
|
|
return tls.VersionSSL30
|
|
|
|
case TLSVersionTLS10:
|
|
|
|
return tls.VersionTLS10
|
|
|
|
case TLSVersionTLS11:
|
|
|
|
return tls.VersionTLS11
|
|
|
|
case TLSVersionTLS12:
|
|
|
|
return tls.VersionTLS12
|
|
|
|
default:
|
|
|
|
return tls.VersionTLS13
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-27 22:26:15 +00:00
|
|
|
type File struct {
|
|
|
|
PublicKeyPath string
|
|
|
|
PrivateKeyPath string
|
|
|
|
}
|
|
|
|
|
|
|
|
type ValidityDuration struct {
|
|
|
|
NotBeforeRelative time.Duration
|
|
|
|
NotAfterRelative time.Duration
|
|
|
|
}
|
|
|
|
|
|
|
|
type ValidityByPurpose struct {
|
|
|
|
CA ValidityDuration
|
|
|
|
Server ValidityDuration
|
|
|
|
}
|
|
|
|
|
|
|
|
type CertOptions struct {
|
2020-06-24 10:25:34 +00:00
|
|
|
RootCACert File
|
|
|
|
CertCachePath string
|
|
|
|
Curve CurveType
|
|
|
|
Validity ValidityByPurpose
|
|
|
|
IncludeInsecureCipherSuites bool
|
|
|
|
MinTLSVersion TLSVersion
|
2020-04-27 22:26:15 +00:00
|
|
|
}
|