Failed to initialize SSL TrustManager

ES Version 7.12
AKS: 1:20.7

Certificate passwords added elastic keystore and value verified

xpack settings true true TLSv1.2 certificate /usr/share/elasticsearch/config/certs/chain-test-rp-search.pfx /usr/share/elasticsearch/config/certs/chain-test-rp-search.pfx true optional certificate /usr/share/elasticsearch/config/certs/chain-test-rp-search-data.pfx /usr/share/elasticsearch/config/certs/chain-test-rp-search-data.pfx

Log Trace

ElasticsearchSecurityException[failed to load SSL configuration []]; nested: ElasticsearchException[failed to initialize SSL TrustManager]; nested: IOException[keystore password was incorrect]; nested: UnrecoverableKeyException[failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.];
Likely root cause: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
        at java.base/
        at java.base/
        at java.base/
        at org.elasticsearch.xpack.core.ssl.TrustConfig.getStore(
        at org.elasticsearch.xpack.core.ssl.StoreTrustConfig.createTrustManager(
        at org.elasticsearch.xpack.core.ssl.SSLService.createSslContext(
        at java.base/java.util.HashMap.computeIfAbsent(
        at org.elasticsearch.xpack.core.ssl.SSLService.lambda$loadSSLConfigurations$5(
        at java.base/java.util.HashMap.forEach(
        at java.base/java.util.Collections$UnmodifiableMap.forEach(
        at org.elasticsearch.xpack.core.ssl.SSLService.loadSSLConfigurations(
        at org.elasticsearch.xpack.core.ssl.SSLService.<init>(
        at org.elasticsearch.xpack.core.XPackPlugin.createSSLService(
        at org.elasticsearch.xpack.core.XPackPlugin.createComponents(
        at org.elasticsearch.node.Node.lambda$new$17(
        at java.base/$7$1.accept(
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(
        at java.base/
        at java.base/
        at java.base/$ReduceOp.evaluateSequential(
        at java.base/
        at java.base/
        at org.elasticsearch.node.Node.<init>(
        at org.elasticsearch.node.Node.<init>(
        at org.elasticsearch.bootstrap.Bootstrap$5.<init>(
        at org.elasticsearch.bootstrap.Bootstrap.setup(
        at org.elasticsearch.bootstrap.Bootstrap.init(
        at org.elasticsearch.bootstrap.Elasticsearch.init(
        at org.elasticsearch.bootstrap.Elasticsearch.execute(
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(

The only plausible reason for seeing that error message is that your value isn't correct.

I know you said you verified it, but how did you verify it? Is it possible you had a typo while entering it into the keystore?
Or is it possible that it's been added to the wrong keystore (if you have multiple installs of Elasticsearch)?

There are multiple issues

Issue #1

  • We generated selfsigned password protected PFX file (with full chain).
  • Verified the chain with below command
keytool -list -keystone fullChainCert.pfx -storetype pkcs12 -v
  • We uploaded the PFX file to Azure Portal, it removes the password
  • So, essentially our PFX file becomes password free
  • This is the root cause of the this error, trying to supply password for PFX file that wasn't protected with password

Issue #2

  • We automatically sync PFX file using CSI driver and ManagedIdentity
  • We tried our luck by removing passwords in elastisearch.yaml file. That didn't work, we were getting Empty certificate chain error
  • Not sure where issue was, it could be the Elasticsearch, Azure KeyVault or both
  • One thing we noticed was Azure CSi driver sync'ed PFX file doe not pass verification
keytool -list -keystone fullChainCert.pfx -storetype pkcs12 -v

How we resolved

  • Encrypted PFX private key with AES256 alg
  • Created a private Elasticsearch Image that has all PEM files (rootCA, IssueingCA, cert and encrypted key) located in /usr/share/Elasticsearch/config/certs folder
  • Synced ASE decryption key from Azure using CSI driver
  • We did not like this solution but our PROD has 200 machines & we need an automated way to enable TLS/SSL

If anyone has a better way let us know!!!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.