Documentation
¶
Overview ¶
Package challtestsrv provides a trivially insecure acme challenge response server for rapidly testing HTTP-01, DNS-01 and TLS-ALPN-01 challenge types.
Index ¶
- Constants
- Variables
- type ChallSrv
- func (s *ChallSrv) AddDNSAAAARecord(host string, addresses []string)
- func (s *ChallSrv) AddDNSARecord(host string, addresses []string)
- func (s *ChallSrv) AddDNSCAARecord(host string, policies []MockCAAPolicy)
- func (s *ChallSrv) AddDNSOneChallenge(host, content string)
- func (s *ChallSrv) AddHTTPOneChallenge(token, content string)
- func (s *ChallSrv) AddHTTPRedirect(path, targetURL string)
- func (s *ChallSrv) AddTLSALPNChallenge(host, content string)
- func (s *ChallSrv) DeleteDNSAAAARecord(host string)
- func (s *ChallSrv) DeleteDNSARecord(host string)
- func (s *ChallSrv) DeleteDNSCAARecord(host string)
- func (s *ChallSrv) DeleteDNSOneChallenge(host string)
- func (s *ChallSrv) DeleteHTTPOneChallenge(token string)
- func (s *ChallSrv) DeleteHTTPRedirect(path string)
- func (s *ChallSrv) DeleteTLSALPNChallenge(host string)
- func (s *ChallSrv) GetDNSAAAARecord(host string) []string
- func (s *ChallSrv) GetDNSARecord(host string) []string
- func (s *ChallSrv) GetDNSCAARecord(host string) []MockCAAPolicy
- func (s *ChallSrv) GetDNSOneChallenge(host string) []string
- func (s *ChallSrv) GetDefaultDNSIPv4() string
- func (s *ChallSrv) GetDefaultDNSIPv6() string
- func (s *ChallSrv) GetHTTPOneChallenge(token string) (string, bool)
- func (s *ChallSrv) GetHTTPRedirect(path string) (string, bool)
- func (s *ChallSrv) GetTLSALPNChallenge(host string) (string, bool)
- func (s *ChallSrv) Run()
- func (s *ChallSrv) ServeChallengeCertFunc(k *ecdsa.PrivateKey) func(*tls.ClientHelloInfo) (*tls.Certificate, error)
- func (s *ChallSrv) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *ChallSrv) SetDefaultDNSIPv4(addr string)
- func (s *ChallSrv) SetDefaultDNSIPv6(addr string)
- func (s *ChallSrv) Shutdown()
- type Config
- type MockCAAPolicy
Constants ¶
const ACMETLS1Protocol = "acme-tls/1"
ALPN protocol ID for TLS-ALPN-01 challenge https://tools.ietf.org/html/draft-ietf-acme-tls-alpn-01#section-5.2
Variables ¶
var IdPeAcmeIdentifier = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 31}
As defined in https://tools.ietf.org/html/draft-ietf-acme-tls-alpn-04#section-5.1 id-pe OID + 31 (acmeIdentifier)
Functions ¶
This section is empty.
Types ¶
type ChallSrv ¶
type ChallSrv struct {
// contains filtered or unexported fields
}
ChallSrv is a multi-purpose challenge server. Each ChallSrv may have one or more ACME challenges it provides servers for. It is safe to use concurrently.
func (*ChallSrv) AddDNSAAAARecord ¶
AddDNSAAAARecord adds IPv6 addresses that will be returned when querying for AAAA records for the given host.
func (*ChallSrv) AddDNSARecord ¶
AddDNSARecord adds IPv4 addresses that will be returned when querying for A records for the given host.
func (*ChallSrv) AddDNSCAARecord ¶
func (s *ChallSrv) AddDNSCAARecord(host string, policies []MockCAAPolicy)
AddDNSCAARecord adds mock CAA records that will be returned when querying CAA for the given host.
func (*ChallSrv) AddDNSOneChallenge ¶
AddDNSOneChallenge adds a TXT record for the given host with the given content.
func (*ChallSrv) AddHTTPOneChallenge ¶
AddHTTPOneChallenge adds a new HTTP-01 challenge for the given token and content.
func (*ChallSrv) AddHTTPRedirect ¶
AddHTTPRedirect adds a redirect for the given path to the given URL.
func (*ChallSrv) AddTLSALPNChallenge ¶
AddTLSALPNChallenge adds a new TLS-ALPN-01 key authorization for the given host
func (*ChallSrv) DeleteDNSAAAARecord ¶
DeleteDNSAAAARecord deletes any IPv6 addresses that will be returned when querying for A records for the given host.
func (*ChallSrv) DeleteDNSARecord ¶
DeleteDNSARecord deletes any IPv4 addresses that will be returned when querying for A records for the given host.record for the given host.
func (*ChallSrv) DeleteDNSCAARecord ¶
DeleteDNSCAARecord deletes any CAA policies that will be returned when querying CAA for the given host.
func (*ChallSrv) DeleteDNSOneChallenge ¶
DeleteDNSOneChallenge deletes a TXT record for the given host.
func (*ChallSrv) DeleteHTTPOneChallenge ¶
DeleteHTTPOneChallenge deletes a given HTTP-01 challenge token.
func (*ChallSrv) DeleteHTTPRedirect ¶
DeletedHTTPRedirect deletes a redirect for the given path.
func (*ChallSrv) DeleteTLSALPNChallenge ¶
DeleteTLSALPNChallenge deletes the key authorization for a given host
func (*ChallSrv) GetDNSAAAARecord ¶
GetDNSAAAARecord returns a slice of IPv6 addresses (in string form) that will be returned when querying for A records for the given host.
func (*ChallSrv) GetDNSARecord ¶
GetDNSARecord returns a slice of IPv4 addresses (in string form) that will be returned when querying for A records for the given host.
func (*ChallSrv) GetDNSCAARecord ¶
func (s *ChallSrv) GetDNSCAARecord(host string) []MockCAAPolicy
GetDNSCAARecord returns a slice of mock CAA policies that will be returned when querying CAA for the given host.
func (*ChallSrv) GetDNSOneChallenge ¶
GetDNSOneChallenge returns a slice of TXT record values for the given host. If the host does not exist in the challenge response data then nil is returned.
func (*ChallSrv) GetDefaultDNSIPv4 ¶
GetDefaultDNSIPv4 gets the default IPv4 address used for A query responses (in string form), or an empty string if no default is being used.
func (*ChallSrv) GetDefaultDNSIPv6 ¶
GetDefaultDNSIPv6 gets the default IPv6 address used for AAAA query responses (in string form), or an empty string if no default is being used.
func (*ChallSrv) GetHTTPOneChallenge ¶
GetHTTPOneChallenge returns the HTTP-01 challenge content for the given token (if it exists) and a true bool. If the token does not exist then an empty string and a false bool are returned.
func (*ChallSrv) GetHTTPRedirect ¶
GetHTTPRedirect returns the redirect target for the given path (if it exists) and a true bool. If the path does not have a redirect target then an empty string and a false bool are returned.
func (*ChallSrv) GetTLSALPNChallenge ¶
GetTLSALPNChallenge checks the s.tlsALPNOne map for the given host. If it is present it returns the key authorization and true, if not it returns an empty string and false.
func (*ChallSrv) ServeChallengeCertFunc ¶
func (s *ChallSrv) ServeChallengeCertFunc(k *ecdsa.PrivateKey) func(*tls.ClientHelloInfo) (*tls.Certificate, error)
func (*ChallSrv) ServeHTTP ¶
func (s *ChallSrv) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP handles an HTTP request. If the request path has the ACME HTTP-01 challenge well known prefix as a prefix and the token specified is known, then the challenge response contents are returned.
func (*ChallSrv) SetDefaultDNSIPv4 ¶
SetDefaultDNSIPv4 sets the default IPv4 address used for A query responses that don't match hosts added with AddDNSARecord. Use "" to disable default A query responses.
func (*ChallSrv) SetDefaultDNSIPv6 ¶
SetDefaultDNSIPv6 sets the default IPv6 address used for AAAA query responses that don't match hosts added with AddDNSAAAARecord. Use "" to disable default AAAA query responses.
type Config ¶
type Config struct {
Log *log.Logger
// HTTPOneAddrs are the HTTP-01 challenge server bind addresses/ports
HTTPOneAddrs []string
// HTTPSOneAddrs are the HTTPS HTTP-01 challenge server bind addresses/ports
HTTPSOneAddrs []string
// DNSOneAddrs are the DNS-01 challenge server bind addresses/ports
DNSOneAddrs []string
// TLSALPNOneAddrs are the TLS-ALPN-01 challenge server bind addresses/ports
TLSALPNOneAddrs []string
}
Config holds challenge server configuration
type MockCAAPolicy ¶
MockCAAPolicy holds a tag and a value for a CAA record. See https://tools.ietf.org/html/rfc6844