@@ -217,7 +217,8 @@ type Config struct {
217
217
Certificates []tls.Certificate `yaml:"-"`
218
218
219
219
// TLS version
220
- TLSMinVersion string `yaml:"tls-min-version"`
220
+ TLSMinVersion string `yaml:"tls-min-version"`
221
+ TLSClientAuth tls.ClientAuthType `yaml:"tls-client-auth"`
221
222
222
223
// Exclude insecure cipher suites
223
224
ExcludeInsecureCipherSuites bool `yaml:"exclude-insecure-cipher-suites"`
@@ -523,6 +524,9 @@ func NewConfig() *Config {
523
524
524
525
// TLS version
525
526
flag .StringVar (& cfg .TLSMinVersion , "tls-min-version" , defaultMinTLSVersion , "minimal TLS Version to be used in server, proxy and client connections" )
527
+ flag .Func ("tls-client-auth" , "TLS client authentication policy for server, one of: " +
528
+ "NoClientCert, RequestClientCert, RequireAnyClientCert, VerifyClientCertIfGiven or RequireAndVerifyClientCert. " +
529
+ "See https://pkg.go.dev/crypto/tls#ClientAuthType for details." , cfg .setTLSClientAuth )
526
530
527
531
// Exclude insecure cipher suites
528
532
flag .BoolVar (& cfg .ExcludeInsecureCipherSuites , "exclude-insecure-cipher-suites" , false , "excludes insecure cipher suites" )
@@ -727,6 +731,7 @@ func (c *Config) ToOptions() skipper.Options {
727
731
DebugListener : c .DebugListener ,
728
732
CertPathTLS : c .CertPathTLS ,
729
733
KeyPathTLS : c .KeyPathTLS ,
734
+ TLSClientAuth : c .TLSClientAuth ,
730
735
CipherSuites : c .filterCipherSuites (),
731
736
MaxLoopbacks : c .MaxLoopbacks ,
732
737
DefaultHTTPStatus : c .DefaultHTTPStatus ,
@@ -1047,6 +1052,21 @@ func (c *Config) getMinTLSVersion() uint16 {
1047
1052
return tlsVersionTable [defaultMinTLSVersion ]
1048
1053
}
1049
1054
1055
+ func (c * Config ) setTLSClientAuth (s string ) error {
1056
+ var ok bool
1057
+ c .TLSClientAuth , ok = map [string ]tls.ClientAuthType {
1058
+ "NoClientCert" : tls .NoClientCert ,
1059
+ "RequestClientCert" : tls .RequestClientCert ,
1060
+ "RequireAnyClientCert" : tls .RequireAnyClientCert ,
1061
+ "VerifyClientCertIfGiven" : tls .VerifyClientCertIfGiven ,
1062
+ "RequireAndVerifyClientCert" : tls .RequireAndVerifyClientCert ,
1063
+ }[s ]
1064
+ if ! ok {
1065
+ return fmt .Errorf ("unsupported TLS client authentication type" )
1066
+ }
1067
+ return nil
1068
+ }
1069
+
1050
1070
func (c * Config ) filterCipherSuites () []uint16 {
1051
1071
if ! c .ExcludeInsecureCipherSuites {
1052
1072
return nil
0 commit comments