@@ -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+
262263fn get_ldap_login_identity_provider (
263264 ldap : & ldap:: v1alpha1:: AuthenticationProvider ,
264265) -> Result < String , Error > {
0 commit comments