@@ -30,10 +30,8 @@ use stackable_operator::{
3030} ;
3131
3232use crate :: crd:: {
33- DruidRole ,
34- security:: {
35- DruidTlsSecurity , PLAINTEXT_PORT_NAME , STACKABLE_TLS_DIR , TLS_PORT_NAME , TLS_STORE_PASSWORD ,
36- } ,
33+ DruidRole , STACKABLE_TRUST_STORE_PASSWORD , STACKABLE_TRUST_STORE_TYPE ,
34+ security:: { DruidTlsSecurity , PLAINTEXT_PORT_NAME , STACKABLE_TLS_DIR , TLS_PORT_NAME } ,
3735} ;
3836
3937#[ derive( Snafu , Debug ) ]
@@ -85,8 +83,9 @@ const TLS_ALIAS_NAME: &str = "1";
8583const AUTH_TRUST_STORE_PATH : & str = "druid.auth.basic.ssl.trustStorePath" ;
8684const AUTH_TRUST_STORE_TYPE : & str = "druid.auth.basic.ssl.trustStoreType" ;
8785const AUTH_TRUST_STORE_PASSWORD : & str = "druid.auth.basic.ssl.trustStorePassword" ;
88- // Misc TLS
89- const TLS_STORE_TYPE : & str = "pkcs12" ;
86+ // PKCS12 store file names (within the TLS store directory).
87+ const TRUST_STORE_FILE : & str = "truststore.p12" ;
88+ const KEY_STORE_FILE : & str = "keystore.p12" ;
9089
9190// directories
9291const STACKABLE_MOUNT_TLS_DIR : & str = "/stackable/mount_tls" ;
@@ -162,7 +161,7 @@ pub fn add_tls_volume_and_volume_mounts(
162161 secret_volume_source_builder
163162 . with_pod_scope ( )
164163 . with_format ( SecretFormat :: TlsPkcs12 )
165- . with_tls_pkcs12_password ( TLS_STORE_PASSWORD )
164+ . with_tls_pkcs12_password ( STACKABLE_TRUST_STORE_PASSWORD )
166165 . with_auto_tls_cert_lifetime ( * requested_secret_lifetime) ;
167166
168167 if let Some ( listener_scope) = & listener_scope {
@@ -254,10 +253,13 @@ fn add_pkcs12_store_properties(
254253 path_property. to_string ( ) ,
255254 format ! ( "{store_directory}/{store_file}" ) ,
256255 ) ;
257- config. insert ( type_property. to_string ( ) , TLS_STORE_TYPE . to_string ( ) ) ;
256+ config. insert (
257+ type_property. to_string ( ) ,
258+ STACKABLE_TRUST_STORE_TYPE . to_string ( ) ,
259+ ) ;
258260 config. insert (
259261 password_property. to_string ( ) ,
260- TLS_STORE_PASSWORD . to_string ( ) ,
262+ STACKABLE_TRUST_STORE_PASSWORD . to_string ( ) ,
261263 ) ;
262264}
263265
@@ -271,7 +273,7 @@ fn add_tls_encryption_config_properties(
271273 add_pkcs12_store_properties (
272274 config,
273275 store_directory,
274- "truststore.p12" ,
276+ TRUST_STORE_FILE ,
275277 CLIENT_HTTPS_TRUST_STORE_PATH ,
276278 CLIENT_HTTPS_TRUST_STORE_TYPE ,
277279 CLIENT_HTTPS_TRUST_STORE_PASSWORD ,
@@ -280,7 +282,7 @@ fn add_tls_encryption_config_properties(
280282 add_pkcs12_store_properties (
281283 config,
282284 store_directory,
283- "keystore.p12" ,
285+ KEY_STORE_FILE ,
284286 SERVER_HTTPS_KEY_STORE_PATH ,
285287 SERVER_HTTPS_KEY_STORE_TYPE ,
286288 SERVER_HTTPS_KEY_STORE_PASSWORD ,
@@ -292,7 +294,7 @@ fn add_tls_encryption_config_properties(
292294 add_pkcs12_store_properties (
293295 config,
294296 store_directory,
295- "truststore.p12" ,
297+ TRUST_STORE_FILE ,
296298 AUTH_TRUST_STORE_PATH ,
297299 AUTH_TRUST_STORE_TYPE ,
298300 AUTH_TRUST_STORE_PASSWORD ,
@@ -307,7 +309,7 @@ fn add_tls_auth_config_properties(
307309 add_pkcs12_store_properties (
308310 config,
309311 store_directory,
310- "keystore.p12" ,
312+ KEY_STORE_FILE ,
311313 CLIENT_HTTPS_KEY_STORE_PATH ,
312314 CLIENT_HTTPS_KEY_STORE_TYPE ,
313315 CLIENT_HTTPS_KEY_STORE_PASSWORD ,
@@ -319,7 +321,7 @@ fn add_tls_auth_config_properties(
319321 // javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
320322 config. insert (
321323 CLIENT_HTTPS_KEY_MANAGER_PASSWORD . to_string ( ) ,
322- TLS_STORE_PASSWORD . to_string ( ) ,
324+ STACKABLE_TRUST_STORE_PASSWORD . to_string ( ) ,
323325 ) ;
324326 config. insert ( CLIENT_HTTPS_CERT_ALIAS . to_string ( ) , store_alias. to_string ( ) ) ;
325327 // FIXME: https://github.com/stackabletech/druid-operator/issues/372
@@ -338,7 +340,7 @@ fn add_tls_auth_config_properties(
338340 add_pkcs12_store_properties (
339341 config,
340342 store_directory,
341- "truststore.p12" ,
343+ TRUST_STORE_FILE ,
342344 SERVER_HTTPS_TRUST_STORE_PATH ,
343345 SERVER_HTTPS_TRUST_STORE_TYPE ,
344346 SERVER_HTTPS_TRUST_STORE_PASSWORD ,
@@ -350,7 +352,7 @@ fn add_tls_auth_config_properties(
350352 // javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
351353 config. insert (
352354 SERVER_HTTPS_KEY_MANAGER_PASSWORD . to_string ( ) ,
353- TLS_STORE_PASSWORD . to_string ( ) ,
355+ STACKABLE_TRUST_STORE_PASSWORD . to_string ( ) ,
354356 ) ;
355357 // FIXME: https://github.com/stackabletech/druid-operator/issues/372
356358 // This is required because the client will send its pod ip which is not in the SANs of the certificates
@@ -369,10 +371,12 @@ pub fn build_tls_key_stores_cmd(tls: &DruidTlsSecurity) -> Vec<String> {
369371 // FIXME: *Technically* we should only add the system truststore in case any webPki usage is detected,
370372 // wether that's in S3, LDAP, OIDC, FTE or whatnot.
371373 format!(
372- "cert-tools generate-pkcs12-truststore --pkcs12 '{STACKABLE_MOUNT_TLS_DIR}/truststore.p12:{TLS_STORE_PASSWORD }' --pem /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem --out {STACKABLE_TLS_DIR}/truststore.p12 --out-password '{TLS_STORE_PASSWORD }'"
374+ "cert-tools generate-pkcs12-truststore --pkcs12 '{STACKABLE_MOUNT_TLS_DIR}/{TRUST_STORE_FILE}:{STACKABLE_TRUST_STORE_PASSWORD }' --pem /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem --out {STACKABLE_TLS_DIR}/{TRUST_STORE_FILE} --out-password '{STACKABLE_TRUST_STORE_PASSWORD }'"
373375 ) ,
374376 // We can copy the keystore as is.
375- format!( "cp {STACKABLE_MOUNT_TLS_DIR}/keystore.p12 {STACKABLE_TLS_DIR}/keystore.p12" ) ,
377+ format!(
378+ "cp {STACKABLE_MOUNT_TLS_DIR}/{KEY_STORE_FILE} {STACKABLE_TLS_DIR}/{KEY_STORE_FILE}"
379+ ) ,
376380 ]
377381}
378382
0 commit comments