Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions config/config-network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ metadata:
app.kubernetes.io/version: devel
serving.knative.dev/release: devel
annotations:
knative.dev/example-checksum: "ddc3250f"
knative.dev/example-checksum: "7c86cb6a"
data:
_example: |
################################
Expand Down Expand Up @@ -183,7 +183,7 @@ data:
activator-ca: ""

# The SAN (Subject Alt Name) used to validate the activator TLS certificate.
# It is available only when "activator-ca" is specified.
# It must be set when "activator-ca" is specified.
# Use an empty value to disable the feature (default).
#
# NOTE: This flag is in an alpha state and is mostly here to enable internal testing
Expand Down
9 changes: 9 additions & 0 deletions pkg/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,15 @@ func NewConfigFromMap(data map[string]string) (*Config, error) {
default:
return nil, fmt.Errorf("httpProtocol %s in config-network ConfigMap is not supported", data[HTTPProtocolKey])
}

if nc.ActivatorCA != "" && nc.ActivatorSAN == "" {
return nil, fmt.Errorf("%q must be set when %q was set", ActivatorSANKey, ActivatorCAKey)
}

if nc.ActivatorCA == "" && nc.ActivatorSAN != "" {
return nil, fmt.Errorf("%q must be set when %q was set", ActivatorCAKey, ActivatorSANKey)
}

return nc, nil
}

Expand Down
25 changes: 25 additions & 0 deletions pkg/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,31 @@ func TestConfiguration(t *testing.T) {
c.DefaultExternalScheme = "https"
return c
}(),
}, {
name: "network configuration with activator-ca and activator-san",
data: map[string]string{
ActivatorCAKey: "test-ca",
ActivatorSANKey: "test-san",
},
wantErr: false,
wantConfig: func() *Config {
c := defaultConfig()
c.ActivatorCA = "test-ca"
c.ActivatorSAN = "test-san"
return c
}(),
}, {
name: "network configuration with activator-ca and missing activator-san",
data: map[string]string{
ActivatorCAKey: "test-ca",
},
wantErr: true,
}, {
name: "network configuration with activator-san and missing activator-ca",
data: map[string]string{
ActivatorCAKey: "test-san",
},
wantErr: true,
}, {
name: "legacy keys",
data: map[string]string{
Expand Down