Skip to content

Commit 7b71dde

Browse files
committed
feat: apply TLS profile to COO
This commit passes the TLS configuration read from the cluster TLS profile to the operator's HTTPS server. Signed-off-by: Simon Pasquier <spasquie@redhat.com>
1 parent 4ac2905 commit 7b71dde

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

pkg/operator/operator.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ type OperatorConfiguration struct {
6868
UIPlugins uictrl.UIPluginsConfiguration
6969
FeatureGates FeatureGates
7070
ObservabilityInstaller ObservabilityInstallerConfiguration
71+
TLSProfile configv1.TLSProfileSpec
7172
// CancelFunc is called to trigger graceful shutdown (e.g., on TLS profile change).
7273
CancelFunc context.CancelFunc
7374
}
@@ -155,13 +156,15 @@ func WithCancelFunc(cancel context.CancelFunc) func(*OperatorConfiguration) {
155156

156157
func WithTLSProfile(tlsProfile configv1.TLSProfileSpec) func(*OperatorConfiguration) {
157158
return func(oc *OperatorConfiguration) {
159+
oc.TLSProfile = tlsProfile
158160
oc.UIPlugins.TLSProfile = tlsProfile
159161
}
160162
}
161163

162164
func New(ctx context.Context, cfg *OperatorConfiguration) (*Operator, error) {
163165
restConfig := ctrl.GetConfigOrDie()
164166
scheme := NewScheme(cfg)
167+
setupLog := ctrl.Log.WithName("setup")
165168

166169
metricsOpts := metricsserver.Options{
167170
BindAddress: cfg.MetricsAddr,
@@ -226,10 +229,16 @@ func New(ctx context.Context, cfg *OperatorConfiguration) (*Operator, error) {
226229
ctrl.Log.WithName("events").Info(fmt.Sprintf(format, args...))
227230
})
228231

232+
var tlsConfig tls.Config
233+
tlsConfigFn, unsupportedCiphers := openshifttls.NewTLSConfigFromProfile(cfg.TLSProfile)
234+
if len(unsupportedCiphers) > 0 {
235+
setupLog.Info("Some ciphers from TLS profile are not supported", "ciphers", unsupportedCiphers)
236+
}
237+
tlsConfigFn(&tlsConfig)
238+
tlsConfig.ClientAuth = tls.RequireAndVerifyClientCert
239+
229240
servingCertController = dynamiccertificates.NewDynamicServingCertificateController(
230-
&tls.Config{
231-
ClientAuth: tls.RequireAndVerifyClientCert,
232-
},
241+
&tlsConfig,
233242
clientCAController,
234243
certKeyProvider,
235244
nil,
@@ -322,11 +331,10 @@ func New(ctx context.Context, cfg *OperatorConfiguration) (*Operator, error) {
322331
}
323332

324333
if cfg.FeatureGates.OpenShift.Enabled {
325-
setupLog := ctrl.Log.WithName("setup")
326334

327335
watcher := &openshifttls.SecurityProfileWatcher{
328336
Client: mgr.GetClient(),
329-
InitialTLSProfileSpec: cfg.UIPlugins.TLSProfile,
337+
InitialTLSProfileSpec: cfg.TLSProfile,
330338
OnProfileChange: func(_ context.Context, _, _ configv1.TLSProfileSpec) {
331339
setupLog.Info("TLS security profile changed, triggering graceful restart")
332340
if cfg.CancelFunc != nil {
@@ -342,7 +350,6 @@ func New(ctx context.Context, cfg *OperatorConfiguration) (*Operator, error) {
342350
return nil, fmt.Errorf("unable to register observability-ui-plugin controller: %w", err)
343351
}
344352
} else {
345-
setupLog := ctrl.Log.WithName("setup")
346353
setupLog.Info("OpenShift feature gate is disabled, UIPlugins are not enabled")
347354
}
348355

@@ -351,7 +358,6 @@ func New(ctx context.Context, cfg *OperatorConfiguration) (*Operator, error) {
351358
return nil, fmt.Errorf("unable to register operator controller: %w", err)
352359
}
353360
} else {
354-
setupLog := ctrl.Log.WithName("setup")
355361
setupLog.Info("OpenShift feature gate is disabled, Operator controller is not enabled")
356362
}
357363

@@ -374,7 +380,6 @@ func New(ctx context.Context, cfg *OperatorConfiguration) (*Operator, error) {
374380
return nil, fmt.Errorf("unable to register cluster observability controller: %w", err)
375381
}
376382
} else {
377-
setupLog := ctrl.Log.WithName("setup")
378383
setupLog.Info("OpenShift feature gate is disabled, cluster observability controller is not enabled")
379384
}
380385

0 commit comments

Comments
 (0)