Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge challtestsrv package into Pebble #466

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
12823ae
Initial commit
cpu Dec 5, 2018
5002395
Initial challtestsrv package & vendored deps.
Dec 5, 2018
ede5da4
go mod tidy results
Dec 5, 2018
73f3082
Initial challtestsrv package & vendored deps. (#1)
jsha Dec 6, 2018
6d791a1
Comment tweaks and delete fixes.
jsha Dec 6, 2018
495441a
Merge pull request #2 from letsencrypt/followups
cpu Dec 6, 2018
17a3d10
Track challenge server request history. (#3)
cpu Dec 14, 2018
37390bc
fix: don't panic with unknown DNS question type. (#4)
ldez Jan 4, 2019
618ad7c
Add linting, README badges, code coverage, code of conduct. (#5)
cpu Feb 27, 2019
26580cb
CI: use latest stable Go version (#6)
cpu Mar 15, 2019
285efd6
Add simple support for CNAMEs as DNS aliases (#7)
ryansouza Mar 29, 2019
749354b
dns: add support for mocking SERVFAIL responses. (#10)
Aug 27, 2019
0dd24b5
CI: Fixes for Go 1.13 (#11)
Sep 6, 2019
5b8a09a
ci: update golangci-lint and check go modules (#12)
ldez Feb 12, 2020
ff9b44b
Avoid logging on a clean server shutdown. (#15)
jsha Oct 19, 2021
fdd87b4
Update miekg/dns to latest. (#16)
jsha Oct 19, 2021
c35d6f4
README: remove word "command" since this is a library only package (#17)
Dec 18, 2021
9c61e5c
Reduce TLS support in HTTPS redirection path (#19)
jsha Mar 19, 2022
6b7134b
Add DoH support for DNS challenges and fake data (#21)
jsha Dec 5, 2023
6944a39
fix DoH response writer (#22)
jsha Dec 5, 2023
986f82c
http-01: remove MaxVersion restriction (#23)
jsha Dec 6, 2023
e5e8a88
Move code to subdirectory
mcpherrinm May 24, 2024
e73ff76
Merge remote-tracking branch 'challtestsrv/main'
mcpherrinm May 24, 2024
3a2c27a
Update dependencies to use in-tree challtestsrv
mcpherrinm May 24, 2024
4f2f91a
Fix linter complaints
mcpherrinm May 24, 2024
ed41b53
More linter fixes
mcpherrinm May 24, 2024
59e2782
Use latest golangci-lint
mcpherrinm May 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
env:
CGO_ENABLED: 0
GO_VERSION: stable
GOLANGCI_LINT_VERSION: v1.58.1
GOLANGCI_LINT_VERSION: v1.58.2
SHELLCHECK_SCRIPTS: ./*.sh
jobs:
go-lint-checks:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package challtestsrv

import (
"fmt"
"errors"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -118,7 +118,7 @@ func (c *Config) validate() error {
len(c.HTTPSOneAddrs) < 1 &&
len(c.DNSOneAddrs) < 1 &&
len(c.TLSALPNOneAddrs) < 1 {
return fmt.Errorf(
return errors.New(
"config must specify at least one HTTPOneAddrs entry, one HTTPSOneAddr " +
"entry, one DOHAddrs, one DNSOneAddrs entry, or one TLSALPNOneAddrs entry")
}
Expand Down Expand Up @@ -177,10 +177,7 @@ func New(config Config) (*ChallSrv, error) {

for _, address := range config.DOHAddrs {
challSrv.log.Printf("Creating DoH server on %s\n", address)
s, err := dohServer(address, config.DOHCert, config.DOHCertKey, http.HandlerFunc(challSrv.dohHandler))
if err != nil {
return nil, err
}
s := dohServer(address, config.DOHCert, config.DOHCertKey, http.HandlerFunc(challSrv.dohHandler))
challSrv.servers = append(challSrv.servers, s)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (s *ChallSrv) caaAnswers(q dns.Question) []dns.RR {
}

type writeMsg interface {
WriteMsg(*dns.Msg) error
WriteMsg(msg *dns.Msg) error
}

type dnsToHTTPWriter struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (s *doh) ListenAndServe() error {
}

// dohServer creates a DoH server.
func dohServer(address string, tlsCert, tlsCertKey string, handler http.Handler) (challengeServer, error) {
func dohServer(address string, tlsCert, tlsCertKey string, handler http.Handler) *doh {
return &doh{
&http.Server{
Handler: handler,
Expand All @@ -82,5 +82,5 @@ func dohServer(address string, tlsCert, tlsCertKey string, handler http.Handler)
},
tlsCert,
tlsCertKey,
}, nil
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ func (e DNSRequestEvent) Type() RequestEventType {
// in the question name is removed.
func (e DNSRequestEvent) Key() string {
key := e.Question.Name
if strings.HasSuffix(key, ".") {
key = strings.TrimSuffix(key, ".")
}
return key
return strings.TrimSuffix(key, ".")
}

// TLSALPNRequestEvent corresponds to a TLS request received by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (c challHTTPServer) Shutdown() error {
// resulting challengeServer will run a HTTPS server with a self-signed
// certificate useful for HTTP-01 -> HTTPS HTTP-01 redirect responses. If HTTPS
// is false the resulting challengeServer will run an HTTP server.
func httpOneServer(address string, handler http.Handler, https bool) challengeServer {
func httpOneServer(address string, handler http.Handler, https bool) challHTTPServer {
// If HTTPS is requested build a TLS Config that uses the self-signed
// certificate generated at startup.
var tlsConfig *tls.Config
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (s *ChallSrv) ServeChallengeCertFunc(k *ecdsa.PrivateKey) func(*tls.ClientH
kaHash := sha256.Sum256([]byte(ka))
extValue, err := asn1.Marshal(kaHash[:])
if err != nil {
return nil, fmt.Errorf("failed marshalling hash OCTET STRING: %s", err)
return nil, fmt.Errorf("failed marshaling hash OCTET STRING: %w", err)
}
certTmpl := x509.Certificate{
SerialNumber: big.NewInt(1729),
Expand All @@ -84,7 +84,7 @@ func (s *ChallSrv) ServeChallengeCertFunc(k *ecdsa.PrivateKey) func(*tls.ClientH
}
certBytes, err := x509.CreateCertificate(rand.Reader, &certTmpl, &certTmpl, k.Public(), k)
if err != nil {
return nil, fmt.Errorf("failed creating challenge certificate: %s", err)
return nil, fmt.Errorf("failed creating challenge certificate: %w", err)
}
return &tls.Certificate{
Certificate: [][]byte{certBytes},
Expand All @@ -107,7 +107,7 @@ func (c challTLSServer) ListenAndServe() error {
return c.Server.ListenAndServeTLS("", "")
}

func tlsALPNOneServer(address string, challSrv *ChallSrv) challengeServer {
func tlsALPNOneServer(address string, challSrv *ChallSrv) challTLSServer {
key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/pebble-challtestsrv/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"net/http"

"github.com/letsencrypt/challtestsrv"
"github.com/letsencrypt/pebble/v2/challtestsrv"
)

// clearHistory handles an HTTP POST request to clear the challenge server
Expand Down
2 changes: 1 addition & 1 deletion cmd/pebble-challtestsrv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"os"
"strings"

"github.com/letsencrypt/challtestsrv"
"github.com/letsencrypt/pebble/v2/challtestsrv"
"github.com/letsencrypt/pebble/v2/cmd"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/pebble-challtestsrv/mockdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"
"strings"

"github.com/letsencrypt/challtestsrv"
"github.com/letsencrypt/pebble/v2/challtestsrv"
)

// setDefaultDNSIPv4 handles an HTTP POST request to set the default IPv4
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.21

require (
github.com/go-jose/go-jose/v4 v4.0.1
github.com/letsencrypt/challtestsrv v1.3.2
github.com/miekg/dns v1.1.58
)

Expand Down
10 changes: 0 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ github.com/go-jose/go-jose/v4 v4.0.1 h1:QVEPDE3OluqXBQZDcnNvQrInro2h0e4eqNbnZSWq
github.com/go-jose/go-jose/v4 v4.0.1/go.mod h1:WVf9LFMHh/QVrmqrOfqun0C45tMe3RoiKJMPvgWwLfY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/letsencrypt/challtestsrv v1.3.2 h1:pIDLBCLXR3B1DLmOmkkqg29qVa7DDozBnsOpL9PxmAY=
github.com/letsencrypt/challtestsrv v1.3.2/go.mod h1:Ur4e4FvELUXLGhkMztHOsPIsvGxD/kzSJninOrkM+zc=
github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4=
github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4=
github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -17,19 +14,12 @@ golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ=
golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
2 changes: 1 addition & 1 deletion va/va.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (

"github.com/miekg/dns"

"github.com/letsencrypt/challtestsrv"
"github.com/letsencrypt/pebble/v2/acme"
"github.com/letsencrypt/pebble/v2/challtestsrv"
"github.com/letsencrypt/pebble/v2/core"
"github.com/letsencrypt/pebble/v2/db"
)
Expand Down
12 changes: 0 additions & 12 deletions vendor/github.com/letsencrypt/challtestsrv/.gitignore

This file was deleted.

35 changes: 0 additions & 35 deletions vendor/github.com/letsencrypt/challtestsrv/.golangci.yaml

This file was deleted.

30 changes: 0 additions & 30 deletions vendor/github.com/letsencrypt/challtestsrv/.travis.yml

This file was deleted.

3 changes: 0 additions & 3 deletions vendor/github.com/letsencrypt/challtestsrv/CODE_OF_CONDUCT.md

This file was deleted.

Loading