Hello,
I am trying to set up a PKI realm for authentication and I am having trouble with this. I am using elastic search 5.3.0 and I set up a simple cluster of one node hosted on localhost. My purpose is to authenticate the clients (e-g, using the console with cURL to access the DB) with a PEM certificate.
To do so, I carefully followed the documentation here https://www.elastic.co/guide/en/x-pack/current/pki-realm.html and here https://www.elastic.co/guide/en/x-pack/current/ssl-tls.html .
I used certgen to create my PEM certificates : I generated a (certificate,key) for my one and only node and another (certificate,key) couple for the client. It also generated the CA certificate authority ca.cert. I put the node certificate and the CA certificate in the config/x-pack/ folder.
Then, when I try to run bin/elasticsearch, I am getting a lot of errors. I can't even try the authentication process because I do not manage to enable tls in elastic search. Here are my errors
console error output
[2017-04-20T12:20:12,652][WARN ][o.e.x.s.t.n.SecurityNetty4Transport] [main_node] exception caught on transport layer [[id: 0xc9dc8cf5, L:0.0.0.0/0.0.0.0:9300 ! R:/0:0:0:0:0:0:0:1:45487]], closing connection
io.netty.handler.codec.DecoderException: javax.net.ssl.SSLException: Received fatal alert: certificate_unknown
[...]
Caused by: javax.net.ssl.SSLException: Received fatal alert: certificate_unknown
[...]
[2017-04-20T12:20:12,652][WARN ][o.e.x.s.t.n.SecurityNetty4Transport] [main_node] exception caught on transport layer [[id: 0x87d68d4e, L:0.0.0.0/0.0.0.0:45487 ! R:/0:0:0:0:0:0:0:1:9300]], closing connection
io.netty.handler.codec.DecoderException: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
[...]
Caused by: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
[...]
Caused by: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
[...]
Caused by: java.security.cert.CertificateException: No subject alternative names present
[...]
[2017-04-20T12:20:13,504][WARN ][o.e.x.s.t.n.SecurityNetty4Transport] [main_node] exception caught on transport layer [[id: 0xd0de3aef, L:0.0.0.0/0.0.0.0:9300 ! R:/0:0:0:0:0:0:0:1:45493]], closing connection
io.netty.handler.codec.DecoderException: javax.net.ssl.SSLException: Received fatal alert: certificate_unknown
[...]
Caused by: javax.net.ssl.SSLException: Received fatal alert: certificate_unknown
[...]
[2017-04-20T12:20:13,504][WARN ][o.e.x.s.t.n.SecurityNetty4Transport] [main_node] exception caught on transport layer [[id: 0x838e0c17, L:0.0.0.0/0.0.0.0:45493 ! R:/0:0:0:0:0:0:0:1:9300]], closing connection
io.netty.handler.codec.DecoderException: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
[...]
Caused by: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
[...]
Caused by: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
[...]
Caused by: java.security.cert.CertificateException: No subject alternative names present
[...]
[2017-04-20T12:20:14,504][WARN ][o.e.x.s.t.n.SecurityNetty4Transport] [main_node] exception caught on transport layer [[id: 0x21dab67d, L:0.0.0.0/0.0.0.0:9300 ! R:/0:0:0:0:0:0:0:1:45505]], closing connection
io.netty.handler.codec.DecoderException: javax.net.ssl.SSLException: Received fatal alert: certificate_unknown
[...]
Caused by: javax.net.ssl.SSLException: Received fatal alert: certificate_unknown
[...]
[2017-04-20T12:20:14,504][WARN ][o.e.x.s.t.n.SecurityNetty4Transport] [main_node] exception caught on transport layer [[id: 0x2211c6d4, L:0.0.0.0/0.0.0.0:45505 ! R:/0:0:0:0:0:0:0:1:9300]], closing connection
io.netty.handler.codec.DecoderException: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
[...]
Caused by: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
[...]
Caused by: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
[...]
Caused by: java.security.cert.CertificateException: No subject alternative names present
[...]
and here is my elasticsearch.yml
elasticsearch.yml
cluster.name: my-application
node.name: main_node
#Enabling TLS
xpack.ssl.key: /home/me/elasticsearch-5.3.0/config/x-pack/main_node/main_node.key
xpack.ssl.certificate: /home/me/elasticsearch-5.3.0/config/x-pack/main_node/main_node.crt
xpack.ssl.certificate_authorities: [ "/home/me/elasticsearch-5.3.0/config/x-pack/ca/ca.crt" ]
#tls
xpack.security.transport.ssl.enabled: true
xpack.security.http.ssl.enabled: true
#enabling PKI
xpack:
security:
authc:
realms:
pki1:
type: pki
I am using: openjdk version "1.8.0_111", x-pack 5.3, elastic search 5.3.0
I checked the troubleshooting page https://www.elastic.co/guide/en/x-pack/current/security-troubleshooting.html for these exceptions:
-
No subject alternative names present: When creating the certificates with certgen, I did not specify any ip nor DNS. What I understood from the doc is that it was not required and it would skip the hostname verification. I also tried to create the certificate with ip : 127.0.0.1 (for localhost) and it did not work neither.
-
unkown certificate: I have no clue why my certificates are not recognized. Is it trying to find my CA cert in the Java truststore ? I did define xpack.ssl.certificate_authorities in elasticsearch.yml to use the PEM file generated from certgen.
So, what am I doing wrong here ?
Thank you !