-
Notifications
You must be signed in to change notification settings - Fork 236
6.3 regression: CA keystore missing certificates, AWS plugins not working #171
Description
- Docker image used:
docker.elastic.co/elasticsearch/elasticsearch:6.3.0
- Operating System: Amazon Linux ECS 2018.03.a
Bug Description
The Java CA keystore that ships with the 6.3.0 Docker image is missing many root certificates, which makes both AWS plugins unusable by default as the cert presented by their endpoints will not validate.
I'm updating my ElasticSearch deployments on AWS from 6.2 to 6.3. I have a very simple Dockerfile that just installs the discovery-ec2
and repository-s3
plugins on top of the official ES image. Updating the base image from 6.2.4 to 6.3.0 makes the containers unable to find the cluster with the following exception (note that it's logged as INFO):
[INFO ][o.e.d.e.AwsEc2UnicastHostsProvider] [Aae6Wze] Exception while retrieving instance list from AWS API: Unable to execute HTTP request: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Digging into the issue, the CA keystore in the 6.3 image is half the size of the one in 6.2:
$ docker run docker.elastic.co/elasticsearch/elasticsearch:6.3.0 sh -c '$JAVA_HOME/bin/keytool -cacerts -storepass changeit -list | head -n 4'
Keystore type: JKS
Keystore provider: SUN
Your keystore contains 80 entries
$ docker run docker.elastic.co/elasticsearch/elasticsearch:6.2.4 sh -c '$JAVA_HOME/bin/keytool -keystore "$JAVA_HOME/lib/security/cacerts" -storepass changeit -list | head -n 4'
Keystore type: JKS
Keystore provider: SUN
Your keystore contains 155 entries
For comparison, this is the one on the official OpenJDK 10 Docker image:
$ docker run openjdk:10 sh -c '$JAVA_HOME/bin/keytool -cacerts -storepass changeit -list | head -n 4'
Keystore type: JKS
Keystore provider: SUN
Your keystore contains 133 entries
Workaround
For anyone who finds this problem, the workaround to make the AWS plugins work is to add the AWS root cert on the Docker image. Here is my complete Dockerfile with both plugins and certificate:
FROM docker.elastic.co/elasticsearch/elasticsearch:6.3.0
RUN curl -s https://www.amazontrust.com/repository/SFSRootCAG2.pem | $JAVA_HOME/bin/keytool -cacerts -storepass changeit -importcert -noprompt
RUN for PLUGIN in discovery-ec2 repository-s3; do elasticsearch-plugin install --batch $PLUGIN; done