Skip to content

Commit cb86319

Browse files
authored
httpcaddyfile: Support client auth verifiers (#6022)
* Added verifier case Update author * Update verifier to match struct tag * gci run
1 parent ed41c92 commit cb86319

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

caddyconfig/httpcaddyfile/builtins.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,24 @@ func parseTLS(h Helper) ([]ConfigValue, error) {
219219
for nesting := h.Nesting(); h.NextBlock(nesting); {
220220
subdir := h.Val()
221221
switch subdir {
222+
case "verifier":
223+
if !h.NextArg() {
224+
return nil, h.ArgErr()
225+
}
226+
227+
vType := h.Val()
228+
modID := "tls.client_auth." + vType
229+
unm, err := caddyfile.UnmarshalModule(h.Dispenser, modID)
230+
if err != nil {
231+
return nil, err
232+
}
233+
234+
_, ok := unm.(caddytls.ClientCertificateVerifier)
235+
if !ok {
236+
return nil, h.Dispenser.Errf("module %s is not a caddytls.ClientCertificatVerifier", modID)
237+
}
238+
239+
cp.ClientAuthentication.VerifiersRaw = append(cp.ClientAuthentication.VerifiersRaw, caddyconfig.JSONModuleObject(unm, "verifier", vType, h.warnings))
222240
case "mode":
223241
if !h.Args(&cp.ClientAuthentication.Mode) {
224242
return nil, h.ArgErr()

0 commit comments

Comments
 (0)