@@ -136,22 +136,14 @@ impl NifiAuthenticationConfig {
136
136
}
137
137
Self :: Ldap { provider } => {
138
138
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 ) ) ;
143
140
}
144
141
}
145
142
Self :: Oidc { provider, .. } => {
146
143
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)\" " ) ) ;
150
145
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 ) ) ;
155
147
}
156
148
}
157
149
}
@@ -259,6 +251,15 @@ impl NifiAuthenticationConfig {
259
251
}
260
252
}
261
253
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
+
262
263
fn get_ldap_login_identity_provider (
263
264
ldap : & ldap:: v1alpha1:: AuthenticationProvider ,
264
265
) -> Result < String , Error > {
0 commit comments