Debian Codegraph @

modules/caddypki/acmeserver/challenges.go

raw symbols SCIP
1 package acmeserverscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/
2
3 import (
4 "encoding/jsonscip-go gomod github.com/golang/go/src go1.25.1 `encoding/json`/"
5 "fmtscip-go gomod github.com/golang/go/src go1.25.1 fmt/"
6 "stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/"
7
8 "github.com/smallstep/certificates/authority/provisionerscip-go gomod github.com/smallstep/certificates v0.30.2 `github.com/smallstep/certificates/authority/provisioner`/"
9 )
10
11 // ACMEChallenge is an opaque string that represents supported ACME challenges.
12 type ACMEChallengescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenge# string
13
14 const (
15 HTTP_01scip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/HTTP_01. ACMEChallengescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenge# = "http-01"
16 DNS_01scip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/DNS_01. ACMEChallengescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenge# = "dns-01"
17 TLS_ALPN_01scip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/TLS_ALPN_01. ACMEChallengescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenge# = "tls-alpn-01"
18 )
19
20 // validate checks if the given challenge is supported.
21 func (c ACMEChallengescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenge#) validatescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenge#validate().() error {
22 switch c {
23 case HTTP_01scip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/HTTP_01., DNS_01scip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/DNS_01., TLS_ALPN_01scip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/TLS_ALPN_01.:
24 return nil
25 default:
26 return fmtscip-go gomod github.com/golang/go/src go1.25.1 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.1 fmt/Errorf().("acme challenge %q is not supported", c)
27 }
28 }
29
30 // The unmarshaller first marshals the value into a string. Then it
31 // trims any space around it and lowercase it for normaliztion. The
32 // method does not and should not validate the value within accepted enums.
33 func (c *ACMEChallengescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenge#) UnmarshalJSONscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenge#UnmarshalJSON().(b []byte) error {
34 var s string
35 if err := jsonscip-go gomod github.com/golang/go/src go1.25.1 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.25.1 `encoding/json`/Unmarshal().(b, &s); err != nil {
36 return err
37 }
38 *c = ACMEChallengescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenge#(stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.25.1 strings/ToLower().(stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.25.1 strings/TrimSpace().(s)))
39 return nil
40 }
41
42 // String returns a string representation of the challenge.
43 func (c ACMEChallengescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenge#) Stringscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenge#String().() string {
44 return stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.25.1 strings/ToLower().(string(c))
45 }
46
47 // ACMEChallenges is a list of ACME challenges.
48 type ACMEChallengesscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenges# []ACMEChallengescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenge#
49
50 // validate checks if the given challenges are supported.
51 func (c ACMEChallengesscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenges#) validatescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenges#validate().() error {
52 for _, ch := range c {
53 if err := ch.validatescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenge#validate().(); err != nil {
54 return err
55 }
56 }
57 return nil
58 }
59
60 func (c ACMEChallengesscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenges#) toSmallstepTypescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenges#toSmallstepType().() []provisionerscip-go gomod github.com/smallstep/certificates v0.30.2 `github.com/smallstep/certificates/authority/provisioner`/.ACMEChallengescip-go gomod github.com/smallstep/certificates v0.30.2 `github.com/smallstep/certificates/authority/provisioner`/ACMEChallenge# {
61 if len(c) == 0 {
62 return nil
63 }
64 ac := make([]provisionerscip-go gomod github.com/smallstep/certificates v0.30.2 `github.com/smallstep/certificates/authority/provisioner`/.ACMEChallengescip-go gomod github.com/smallstep/certificates v0.30.2 `github.com/smallstep/certificates/authority/provisioner`/ACMEChallenge#, len(c))
65 for i, ch := range c {
66 ac[i] = provisionerscip-go gomod github.com/smallstep/certificates v0.30.2 `github.com/smallstep/certificates/authority/provisioner`/.ACMEChallengescip-go gomod github.com/smallstep/certificates v0.30.2 `github.com/smallstep/certificates/authority/provisioner`/ACMEChallenge#(ch)
67 }
68 return ac
69 }
70
71 func stringToChallengesscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/stringToChallenges().(chs []string) ACMEChallengesscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenges# {
72 challenges := make(ACMEChallengesscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenges#, len(chs))
73 for i, ch := range chs {
74 challenges[i] = ACMEChallengescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver`/ACMEChallenge#(ch)
75 }
76 return challenges
77 }