@@ -50,7 +50,7 @@ def __init__(self, hostname_verification):
50
50
self ._hostname_verification = os .environ .get (
51
51
self .HOPSWORKS_HOSTNAME_VERIFICATION , "{}" .format (hostname_verification )
52
52
).lower () in ("true" , "1" , "y" , "yes" )
53
- self ._hopsworks_ca_trust_store_path = self ._get_ca_chain_path ()
53
+ self ._hopsworks_ca_trust_store_path = self ._materialize_ca_chain ()
54
54
55
55
self ._project_id = os .environ [self .PROJECT_ID ]
56
56
self ._project_name = self ._project_name ()
@@ -67,10 +67,23 @@ def __init__(self, hostname_verification):
67
67
68
68
credentials = self ._get_credentials (self ._project_id )
69
69
70
- self ._write_pem_file (credentials ["caChain" ], self ._get_ca_chain_path ())
71
70
self ._write_pem_file (credentials ["clientCert" ], self ._get_client_cert_path ())
72
71
self ._write_pem_file (credentials ["clientKey" ], self ._get_client_key_path ())
73
72
73
+ def _materialize_ca_chain (self ):
74
+ """Convert truststore from jks to pem and return the location"""
75
+ ca_chain_path = self ._get_ca_chain_path ()
76
+ if not ca_chain_path .exists ():
77
+ keystore_pw = self ._cert_key
78
+ ks = jks .KeyStore .load (
79
+ self ._get_jks_key_store_path (), keystore_pw , try_decrypt_keys = True
80
+ )
81
+ ts = jks .KeyStore .load (
82
+ self ._get_jks_trust_store_path (), keystore_pw , try_decrypt_keys = True
83
+ )
84
+ self ._write_ca_chain (ks , ts , ca_chain_path )
85
+ return str (ca_chain_path )
86
+
74
87
def _get_hopsworks_rest_endpoint (self ):
75
88
"""Get the hopsworks REST endpoint for making requests to the REST API."""
76
89
return os .environ [self .REST_ENDPOINT ]
0 commit comments