Skip to content

Commit

Permalink
tls: fallback to self-signed certificate (#2760)
Browse files Browse the repository at this point in the history
* tls: fallback to self-signed certificate

* remove unknown domain because certs are no longer valid

* update multi-deployment to use service-specific certificates
  • Loading branch information
calebdoxsey committed Nov 15, 2021
1 parent 9b3d574 commit ca48052
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 80 deletions.
2 changes: 1 addition & 1 deletion config/envoyconfig/listeners.go
Expand Up @@ -532,7 +532,7 @@ func (b *Builder) buildGRPCListener(ctx context.Context, cfg *config.Config) (*e
return li, nil
}

chains, err := b.buildFilterChains(cfg.Options, cfg.Options.Addr,
chains, err := b.buildFilterChains(cfg.Options, cfg.Options.GRPCAddr,
func(tlsDomain string, httpDomains []string) (*envoy_config_listener_v3.FilterChain, error) {
filterChain := &envoy_config_listener_v3.FilterChain{
Filters: []*envoy_config_listener_v3.Filter{filter},
Expand Down
12 changes: 4 additions & 8 deletions integration/clusters/auth0-multi/compose.yml

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions integration/clusters/azure-multi/compose.yml

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions integration/clusters/github-multi/compose.yml

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions integration/clusters/gitlab-multi/compose.yml

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions integration/clusters/google-multi/compose.yml

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions integration/clusters/oidc-multi/compose.yml

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions integration/clusters/okta-multi/compose.yml

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions integration/clusters/onelogin-multi/compose.yml

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions integration/clusters/ping-multi/compose.yml

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion integration/control_plane_test.go
Expand Up @@ -75,7 +75,6 @@ func TestHealth(t *testing.T) {
"https://authenticate.localhost.pomerium.io",
"https://httpdetails.localhost.pomerium.io",
"https://restricted-httpdetails.localhost.pomerium.io",
"https://unknown.localhost.pomerium.io",
}
endpoints := []string{"healthz", "ping"}

Expand Down
5 changes: 4 additions & 1 deletion integration/tpl/backends/pomerium.libsonnet
Expand Up @@ -102,7 +102,6 @@ local Environment(mode, idp, dns_suffix) =
DATABROKER_SERVICE_URL: 'https://pomerium-databroker:5443',
GRPC_ADDRESS: ':5443',
GRPC_INSECURE: 'false',
OVERRIDE_CERTIFICATE_NAME: '*.localhost.pomerium.io',
} else if mode == 'traefik' then {
FORWARD_AUTH_URL: 'https://forward-authenticate.localhost.pomerium.io',
} else if mode == 'nginx' then {
Expand Down Expand Up @@ -141,6 +140,8 @@ function(mode, idp, dns_suffix='') {
image: image,
environment: environment {
SERVICES: 'authorize',
CERTIFICATE: std.base64(importstr '../files/pomerium-authorize.pem'),
CERTIFICATE_KEY: std.base64(importstr '../files/pomerium-authorize-key.pem'),
},
ports: [
'9904:9901/tcp',
Expand All @@ -161,6 +162,8 @@ function(mode, idp, dns_suffix='') {
image: image,
environment: environment {
SERVICES: 'databroker',
CERTIFICATE: std.base64(importstr '../files/pomerium-databroker.pem'),
CERTIFICATE_KEY: std.base64(importstr '../files/pomerium-databroker-key.pem'),
},
ports: [
'9902:9901/tcp',
Expand Down
7 changes: 3 additions & 4 deletions pkg/cryptutil/tls.go
Expand Up @@ -55,10 +55,9 @@ func GetCertificateForDomain(certificates []tls.Certificate, domain string) (*tl
}
}

// next use the first cert
if len(certificates) > 0 {
return &certificates[0], nil
}
log.Error(context.Background()).
Str("domain", domain).
Msg("cryptutil: no TLS certificate found for domain, using self-signed certificate")

// finally fall back to a generated, self-signed certificate
return GenerateSelfSignedCertificate(domain)
Expand Down
3 changes: 2 additions & 1 deletion pkg/cryptutil/tls_test.go
Expand Up @@ -49,7 +49,8 @@ func TestGetCertificateForDomain(t *testing.T) {
if !assert.NoError(t, err) {
return
}
assert.Equal(t, &certs[0], found)
assert.NotNil(t, found)
assert.NotEqual(t, &certs[0], found)
})
t.Run("generate", func(t *testing.T) {
certs := []tls.Certificate{}
Expand Down

0 comments on commit ca48052

Please sign in to comment.