Skip to content

Commit 6f84bb1

Browse files
authored
fix: Prevent missing certificates (#844)
* fix: Prevent missing certificates * changelog * chore: Increase test timeouts
1 parent d89e1bb commit 6f84bb1

File tree

8 files changed

+30
-17
lines changed

8 files changed

+30
-17
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@ All notable changes to this project will be documented in this file.
88

99
- Helm: Allow Pod `priorityClassName` to be configured ([#840]).
1010

11+
### Fixed
12+
13+
- Previously we had a bug that could lead to missing certificates ([#844]).
14+
15+
This could be the case when you specified multiple CAs in your SecretClass.
16+
We now correctly handle multiple certificates in this cases.
17+
See [this GitHub issue](https://github.com/stackabletech/issues/issues/764) for details
18+
1119
[#840]: https://github.com/stackabletech/nifi-operator/pull/840
20+
[#844]: https://github.com/stackabletech/nifi-operator/pull/844
1221

1322
## [25.7.0] - 2025-07-23
1423

rust/operator-binary/src/controller.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,9 @@ async fn build_node_rolegroup_statefulset(
951951
));
952952
}
953953

954+
// Note(sbernauer): In https://github.com/stackabletech/issues/issues/764 we migrated all usages
955+
// of keytool to our own cert-utils tool. As it uses the same code as secret-operator, it also
956+
// uses RC2. Thus, the keytool usage here LGTM (no alias trickery) and has my nod of approval.
954957
prepare_args.extend(vec![
955958
// The source directory is a secret-op mount and we do not want to write / add anything in there
956959
// Therefore we import all the contents to a truststore in "writeable" empty dirs.

rust/operator-binary/src/security/authentication.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,14 @@ impl NifiAuthenticationConfig {
136136
}
137137
Self::Ldap { provider } => {
138138
if let Some(ca_path) = provider.tls.tls_ca_cert_mount_path() {
139-
commands.extend(vec![
140-
"echo Adding LDAP tls cert to global truststore".to_string(),
141-
format!("keytool -importcert -file {ca_path} -keystore {STACKABLE_SERVER_TLS_DIR}/truststore.p12 -storetype pkcs12 -noprompt -alias ldap_ca_cert -storepass {STACKABLE_TLS_STORE_PASSWORD}"),
142-
]);
139+
commands.push(add_cert_to_truststore(&ca_path, STACKABLE_SERVER_TLS_DIR));
143140
}
144141
}
145142
Self::Oidc { provider, .. } => {
146143
let (_, admin_password_file) = self.get_user_and_password_file_paths();
147-
commands.extend(vec![
148-
format!("export STACKABLE_ADMIN_PASSWORD=\"$(cat {admin_password_file} | java -jar /bin/stackable-bcrypt.jar)\""),
149-
]);
144+
commands.push(format!("export STACKABLE_ADMIN_PASSWORD=\"$(cat {admin_password_file} | java -jar /bin/stackable-bcrypt.jar)\""));
150145
if let Some(ca_path) = provider.tls.tls_ca_cert_mount_path() {
151-
commands.extend(vec![
152-
"echo Adding OIDC tls cert to global truststore".to_string(),
153-
format!("keytool -importcert -file {ca_path} -keystore {STACKABLE_SERVER_TLS_DIR}/truststore.p12 -storetype pkcs12 -noprompt -alias oidc_ca_cert -storepass {STACKABLE_TLS_STORE_PASSWORD}"),
154-
]);
146+
commands.push(add_cert_to_truststore(&ca_path, STACKABLE_SERVER_TLS_DIR));
155147
}
156148
}
157149
}
@@ -259,6 +251,15 @@ impl NifiAuthenticationConfig {
259251
}
260252
}
261253

254+
/// Adds a PEM file to configured PKCS12 truststore (using the [`STACKABLE_TLS_STORE_PASSWORD`]
255+
/// password)
256+
fn add_cert_to_truststore(cert_file: &str, destination_directory: &str) -> String {
257+
let truststore = format!("{destination_directory}/truststore.p12");
258+
format!(
259+
"cert-tools generate-pkcs12-truststore --pkcs12 {truststore}:{STACKABLE_TLS_STORE_PASSWORD} --pem {cert_file} --out {truststore} --out-password {STACKABLE_TLS_STORE_PASSWORD}"
260+
)
261+
}
262+
262263
fn get_ldap_login_identity_provider(
263264
ldap: &ldap::v1alpha1::AuthenticationProvider,
264265
) -> Result<String, Error> {

tests/templates/kuttl/external-access/30-assert.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ apiVersion: kuttl.dev/v1beta1
33
kind: TestAssert
44
metadata:
55
name: install-nifi
6-
timeout: 300
6+
timeout: 1200
77
commands:
8-
- script: kubectl -n $NAMESPACE wait --for=condition=available=true nificlusters.nifi.stackable.tech/test-nifi --timeout 301s
8+
- script: kubectl -n $NAMESPACE wait --for=condition=available=true nificlusters.nifi.stackable.tech/test-nifi --timeout 1201s
99
---
1010
apiVersion: apps/v1
1111
kind: StatefulSet

tests/templates/kuttl/ldap/03-assert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
apiVersion: kuttl.dev/v1beta1
33
kind: TestAssert
4-
timeout: 300
4+
timeout: 1200
55
---
66
apiVersion: apps/v1
77
kind: StatefulSet

tests/templates/kuttl/smoke_v1/50-assert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
apiVersion: kuttl.dev/v1beta1
33
kind: TestAssert
4-
timeout: 300
4+
timeout: 1200
55
---
66
apiVersion: apps/v1
77
kind: StatefulSet

tests/templates/kuttl/smoke_v2/50-assert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
apiVersion: kuttl.dev/v1beta1
33
kind: TestAssert
4-
timeout: 300
4+
timeout: 1200
55
---
66
apiVersion: apps/v1
77
kind: StatefulSet

tests/templates/kuttl/upgrade/03-assert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
apiVersion: kuttl.dev/v1beta1
33
kind: TestAssert
4-
timeout: 300
4+
timeout: 1200
55
---
66
apiVersion: apps/v1
77
kind: StatefulSet

0 commit comments

Comments
 (0)