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

Fix #626 panic on invalid tls config in secret #627

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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: 1 addition & 3 deletions config/sink/tls-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ metadata:
namespace: knative-sinks
stringData:
# the data is abbreviated in this example
TLS_CERT: |+
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
TLS_CERT: ""
4 changes: 1 addition & 3 deletions config/source/tls-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ metadata:
namespace: knative-sources
stringData:
# the data is abbreviated in this example
TLS_CERT: |+
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
TLS_CERT: ""
5 changes: 3 additions & 2 deletions pkg/sink/reconciler/streamsink/streamsink.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ func (r *Reconciler) updateTLSSecret(ctx context.Context, secret *corev1.Secret)
tlsSecret, err := GetTLSSecret(secret.Data)
if err != nil {
logging.FromContext(ctx).Errorw("Error reading TLS configuration", zap.Error(err))
} else {
// For now just override the previous config.
r.tlsCert = tlsSecret.TLSCertificate
}
// For now just override the previous config.
r.tlsCert = tlsSecret.TLSCertificate
}
2 changes: 1 addition & 1 deletion pkg/source/adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (a *Adapter) newPool(address string) *redis.Pool {
roots := x509.NewCertPool()
ok := roots.AppendCertsFromPEM([]byte(a.config.TLSCertificate))
if !ok {
panic(err)
panic("cannot add tls certificate to cert pool")
}
c, err = redis.Dial("tcp", opt.Addr,
redis.DialUsername(opt.Username),
Expand Down
10 changes: 6 additions & 4 deletions pkg/source/reconciler/streamsource/streamsource.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,18 @@ func (r *Reconciler) updateRedisConfig(ctx context.Context, configMap *corev1.Co
redisConfig, err := GetRedisConfig(configMap.Data)
if err != nil {
logging.FromContext(ctx).Errorw("Error reading Redis configuration", zap.Error(err))
} else {
// For now just override the previous config.
r.numConsumers = redisConfig.NumConsumers
}
// For now just override the previous config.
r.numConsumers = redisConfig.NumConsumers
}

func (r *Reconciler) updateTLSSecret(ctx context.Context, secret *corev1.Secret) {
tlsSecret, err := GetTLSSecret(secret.Data)
if err != nil {
logging.FromContext(ctx).Errorw("Error reading TLS configuration", zap.Error(err))
} else {
// For now just override the previous config.
r.tlsCert = tlsSecret.TLSCertificate
}
// For now just override the previous config.
r.tlsCert = tlsSecret.TLSCertificate
}
Loading