ACME Default Certificate
Co-authored-by: Ludovic Fernandez <ldez@users.noreply.github.com> Co-authored-by: Julien Salleyron <julien.salleyron@gmail.com>
This commit is contained in:
parent
693d5da1b9
commit
a002ccfce3
22 changed files with 767 additions and 253 deletions
|
@ -40,6 +40,7 @@ type acmeTestCase struct {
|
|||
}
|
||||
|
||||
type templateModel struct {
|
||||
Domain types.Domain
|
||||
Domains []types.Domain
|
||||
PortHTTP string
|
||||
PortHTTPS string
|
||||
|
@ -149,6 +150,29 @@ func (s *AcmeSuite) TestHTTP01Domains(c *check.C) {
|
|||
s.retrieveAcmeCertificate(c, testCase)
|
||||
}
|
||||
|
||||
func (s *AcmeSuite) TestHTTP01StoreDomains(c *check.C) {
|
||||
testCase := acmeTestCase{
|
||||
traefikConfFilePath: "fixtures/acme/acme_store_domains.toml",
|
||||
subCases: []subCases{{
|
||||
host: acmeDomain,
|
||||
expectedCommonName: acmeDomain,
|
||||
expectedAlgorithm: x509.RSA,
|
||||
}},
|
||||
template: templateModel{
|
||||
Domain: types.Domain{
|
||||
Main: "traefik.acme.wtf",
|
||||
},
|
||||
Acme: map[string]static.CertificateResolver{
|
||||
"default": {ACME: &acme.Configuration{
|
||||
HTTPChallenge: &acme.HTTPChallenge{EntryPoint: "web"},
|
||||
}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
s.retrieveAcmeCertificate(c, testCase)
|
||||
}
|
||||
|
||||
func (s *AcmeSuite) TestHTTP01DomainsInSAN(c *check.C) {
|
||||
testCase := acmeTestCase{
|
||||
traefikConfFilePath: "fixtures/acme/acme_domains.toml",
|
||||
|
|
60
integration/fixtures/acme/acme_store_domains.toml
Normal file
60
integration/fixtures/acme/acme_store_domains.toml
Normal file
|
@ -0,0 +1,60 @@
|
|||
[global]
|
||||
checkNewVersion = false
|
||||
sendAnonymousUsage = false
|
||||
|
||||
[log]
|
||||
level = "DEBUG"
|
||||
|
||||
[entryPoints]
|
||||
[entryPoints.web]
|
||||
address = "{{ .PortHTTP }}"
|
||||
[entryPoints.websecure]
|
||||
address = "{{ .PortHTTPS }}"
|
||||
|
||||
{{range $name, $resolvers := .Acme }}
|
||||
|
||||
[certificatesResolvers.{{ $name }}.acme]
|
||||
email = "test@traefik.io"
|
||||
storage = "/tmp/acme.json"
|
||||
keyType = "{{ $resolvers.ACME.KeyType }}"
|
||||
caServer = "{{ $resolvers.ACME.CAServer }}"
|
||||
|
||||
{{if $resolvers.ACME.HTTPChallenge }}
|
||||
[certificatesResolvers.{{ $name }}.acme.httpChallenge]
|
||||
entryPoint = "{{ $resolvers.ACME.HTTPChallenge.EntryPoint }}"
|
||||
{{end}}
|
||||
|
||||
{{if $resolvers.ACME.TLSChallenge }}
|
||||
[certificatesResolvers.{{ $name }}.acme.tlsChallenge]
|
||||
{{end}}
|
||||
|
||||
{{end}}
|
||||
|
||||
[api]
|
||||
insecure = true
|
||||
|
||||
[providers.file]
|
||||
filename = "{{ .SelfFilename }}"
|
||||
|
||||
## dynamic configuration ##
|
||||
|
||||
[http.services]
|
||||
[http.services.test.loadBalancer]
|
||||
[[http.services.test.loadBalancer.servers]]
|
||||
url = "http://127.0.0.1:9010"
|
||||
|
||||
[http.routers]
|
||||
[http.routers.test]
|
||||
entryPoints = ["websecure"]
|
||||
rule = "PathPrefix(`/`)"
|
||||
service = "test"
|
||||
[http.routers.test.tls]
|
||||
|
||||
[tls.stores]
|
||||
[tls.stores.default.defaultGeneratedCert]
|
||||
resolver = "default"
|
||||
[tls.stores.default.defaultGeneratedCert.domain]
|
||||
main = "{{ .Domain.Main }}"
|
||||
sans = [{{range .Domain.SANs }}
|
||||
"{{.}}",
|
||||
{{end}}]
|
|
@ -1870,6 +1870,27 @@ spec:
|
|||
required:
|
||||
- secretName
|
||||
type: object
|
||||
defaultGeneratedCert:
|
||||
description: DefaultGeneratedCert defines the default generated certificate
|
||||
configuration.
|
||||
properties:
|
||||
domain:
|
||||
description: Domain is the domain definition for the DefaultCertificate.
|
||||
properties:
|
||||
main:
|
||||
description: Main defines the main domain name.
|
||||
type: string
|
||||
sans:
|
||||
description: SANs defines the subject alternative domain names.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
resolver:
|
||||
description: Resolver is the name of the resolver that will be
|
||||
used to issue the DefaultCertificate.
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
required:
|
||||
- metadata
|
||||
|
|
|
@ -325,7 +325,7 @@ func (s *HTTPSSuite) TestWithDefaultCertificate(c *check.C) {
|
|||
|
||||
cs := conn.ConnectionState()
|
||||
err = cs.PeerCertificates[0].VerifyHostname("snitest.com")
|
||||
c.Assert(err, checker.IsNil, check.Commentf("certificate did not serve correct default certificate"))
|
||||
c.Assert(err, checker.IsNil, check.Commentf("server did not serve correct default certificate"))
|
||||
|
||||
proto := cs.NegotiatedProtocol
|
||||
c.Assert(proto, checker.Equals, "h2")
|
||||
|
@ -360,7 +360,7 @@ func (s *HTTPSSuite) TestWithDefaultCertificateNoSNI(c *check.C) {
|
|||
|
||||
cs := conn.ConnectionState()
|
||||
err = cs.PeerCertificates[0].VerifyHostname("snitest.com")
|
||||
c.Assert(err, checker.IsNil, check.Commentf("certificate did not serve correct default certificate"))
|
||||
c.Assert(err, checker.IsNil, check.Commentf("server did not serve correct default certificate"))
|
||||
|
||||
proto := cs.NegotiatedProtocol
|
||||
c.Assert(proto, checker.Equals, "h2")
|
||||
|
@ -397,7 +397,7 @@ func (s *HTTPSSuite) TestWithOverlappingStaticCertificate(c *check.C) {
|
|||
|
||||
cs := conn.ConnectionState()
|
||||
err = cs.PeerCertificates[0].VerifyHostname("www.snitest.com")
|
||||
c.Assert(err, checker.IsNil, check.Commentf("certificate did not serve correct default certificate"))
|
||||
c.Assert(err, checker.IsNil, check.Commentf("server did not serve correct default certificate"))
|
||||
|
||||
proto := cs.NegotiatedProtocol
|
||||
c.Assert(proto, checker.Equals, "h2")
|
||||
|
@ -434,7 +434,7 @@ func (s *HTTPSSuite) TestWithOverlappingDynamicCertificate(c *check.C) {
|
|||
|
||||
cs := conn.ConnectionState()
|
||||
err = cs.PeerCertificates[0].VerifyHostname("www.snitest.com")
|
||||
c.Assert(err, checker.IsNil, check.Commentf("certificate did not serve correct default certificate"))
|
||||
c.Assert(err, checker.IsNil, check.Commentf("server did not serve correct default certificate"))
|
||||
|
||||
proto := cs.NegotiatedProtocol
|
||||
c.Assert(proto, checker.Equals, "h2")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue