|
@@ -65,22 +65,34 @@ var allTLSVersions = map[uint16]struct{}{
|
|
}
|
|
}
|
|
|
|
|
|
// ServerDefault returns a secure-enough TLS configuration for the server TLS configuration.
|
|
// ServerDefault returns a secure-enough TLS configuration for the server TLS configuration.
|
|
-func ServerDefault() *tls.Config {
|
|
|
|
- return &tls.Config{
|
|
|
|
- // Avoid fallback to SSL protocols < TLS1.0
|
|
|
|
|
|
+func ServerDefault(ops ...func(*tls.Config)) *tls.Config {
|
|
|
|
+ tlsconfig := &tls.Config{
|
|
|
|
+ // Avoid fallback by default to SSL protocols < TLS1.0
|
|
MinVersion: tls.VersionTLS10,
|
|
MinVersion: tls.VersionTLS10,
|
|
PreferServerCipherSuites: true,
|
|
PreferServerCipherSuites: true,
|
|
CipherSuites: DefaultServerAcceptedCiphers,
|
|
CipherSuites: DefaultServerAcceptedCiphers,
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ for _, op := range ops {
|
|
|
|
+ op(tlsconfig)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return tlsconfig
|
|
}
|
|
}
|
|
|
|
|
|
// ClientDefault returns a secure-enough TLS configuration for the client TLS configuration.
|
|
// ClientDefault returns a secure-enough TLS configuration for the client TLS configuration.
|
|
-func ClientDefault() *tls.Config {
|
|
|
|
- return &tls.Config{
|
|
|
|
|
|
+func ClientDefault(ops ...func(*tls.Config)) *tls.Config {
|
|
|
|
+ tlsconfig := &tls.Config{
|
|
// Prefer TLS1.2 as the client minimum
|
|
// Prefer TLS1.2 as the client minimum
|
|
MinVersion: tls.VersionTLS12,
|
|
MinVersion: tls.VersionTLS12,
|
|
CipherSuites: clientCipherSuites,
|
|
CipherSuites: clientCipherSuites,
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ for _, op := range ops {
|
|
|
|
+ op(tlsconfig)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return tlsconfig
|
|
}
|
|
}
|
|
|
|
|
|
// certPool returns an X.509 certificate pool from `caFile`, the certificate file.
|
|
// certPool returns an X.509 certificate pool from `caFile`, the certificate file.
|