forked from ketch-com/orlop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_auth_value.go
More file actions
48 lines (36 loc) · 768 Bytes
/
client_auth_value.go
File metadata and controls
48 lines (36 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package orlop
import (
"crypto/tls"
"fmt"
)
func newClientAuthValue() *clientAuthValue {
return &clientAuthValue{
v: tls.NoClientCert,
}
}
type clientAuthValue struct {
v tls.ClientAuthType
}
func (c clientAuthValue) String() string {
return fmt.Sprintf("%d", c.v)
}
func (c *clientAuthValue) Set(s string) error {
switch s {
case "request":
c.v = tls.RequestClientCert
case "require":
c.v = tls.RequireAnyClientCert
case "verify":
c.v = tls.VerifyClientCertIfGiven
case "require-and-verify":
c.v = tls.RequireAndVerifyClientCert
case "none":
c.v = tls.NoClientCert
default:
return fmt.Errorf("config: '%s' is not a valid ClientAuth value", s)
}
return nil
}
func (c clientAuthValue) Type() string {
return "ClientAuthType"
}