I have configured the Kibana being connected to ES 7.3.0 with HTTPS enabled. But I got this error "java.io.IOException: Host name 'localhost' does not match the certificate subject provided by the peer (CN=Elastic Certificate Tool Autogenerated CA)"
Actually I encountered the same issue in Kibana and then I set this in the kibana.yml and it worked: elasticsearch.ssl.verificationMode: certificate
Here is the command I used:
sudo /usr/share/elasticsearch/bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12 --dns localhost --ip 127.0.0.1,::1 --name node-sni --out node-sni.p12
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
I thought it was due to the root certificate is not present in the java's cacert
so I ran the following commands:
openssl s_client -showcerts -connect localhost:9200
copy the certificate between BEGIN and END into ca.pem
sudo openssl x509 -in ca.pem -outform der -out ca.der
sudo openssl x509 -in ccc/ca/ca.crt -outform der -out ca.der
sudo keytool -import -alias elastic-ca -keystore /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts -file ca.der
And now the error is:
Caused by: javax.net.ssl.SSLPeerUnverifiedException: Host name 'localhost' does not match the certificate subject provided by the peer (CN=Elastic Certificate Tool Autogenerated CA)
Here are the details of these two entries in the java's cacert:
xxx@elk:~$ sudo keytool -list -alias elastic-ca -keystore /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts -v
Enter keystore password:
Alias name: elastic-ca
Creation date: Oct 14, 2019
Entry type: trustedCertEntry
Owner: CN=Elastic Certificate Tool Autogenerated CA
Issuer: CN=Elastic Certificate Tool Autogenerated CA
Serial number: d9198dfc08cdec68978d431691caac7c3ef75bac
Valid from: Sun Oct 13 20:57:42 AEDT 2019 until: Wed Oct 12 20:57:42 AEDT 2022
Certificate fingerprints:
MD5: A7:AB:C0:CA:67:84:3F:32:1B:55:79:0D:23:C7:FF:69
SHA1: 82:C4:C2:0E:CE:1B:29:26:52:83:39:B5:BF:8D:63:E3:5E:0A:B3:67
SHA256: 29:37:C7:67:8C:14:93:A9:97:38:53:63:05:B9:E8:85:53:EC:28:A3:2E:D6:24:7D:25:F3:F1:FA:1D:09:72:AF
Signature algorithm name: SHA256withRSA
Subject Public Key Algorithm: 2048-bit RSA key
Version: 3
Extensions:
#1: ObjectId: 2.5.29.35 Criticality=false
AuthorityKeyIdentifier [
KeyIdentifier [
0000: F3 F3 90 88 1F CE E7 96 3D FA B5 9B A8 6A EC 1F ........=....j..
0010: C1 07 CA 25 ...%
]
]
#2: ObjectId: 2.5.29.19 Criticality=true
BasicConstraints:[
CA:true
PathLen:2147483647
]
#3: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: F3 F3 90 88 1F CE E7 96 3D FA B5 9B A8 6A EC 1F ........=....j..
0010: C1 07 CA 25 ...%
]
]
xxx@elk:~$ sudo keytool -list -alias elastic -keystore /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts -v Enter keystore password:
Alias name: elastic
Creation date: Oct 14, 2019
Entry type: trustedCertEntry
Owner: CN=node-xxx
Issuer: CN=Elastic Certificate Tool Autogenerated CA
Serial number: d54b56ac15611a3c61fbdc9980d7a2e831f7ed7e
Valid from: Mon Oct 14 18:11:30 AEDT 2019 until: Thu Oct 13 18:11:30 AEDT 2022
Certificate fingerprints:
MD5: 52:2C:0B:42:A6:0E:57:53:3B:08:BE:03:90:B3:99:7A
SHA1: B2:50:1B:AA:57:C0:58:B6:C6:C9:3E:70:C0:23:CA:19:5A:3E:F1:EC
SHA256: C0:E7:B8:AF:08:53:33:4D:F3:22:23:61:18:23:64:A2:20:82:BE:5A:39:1B:7E:DA:84:E5:1B:D8:9D:AD:FB:06
Signature algorithm name: SHA256withRSA
Subject Public Key Algorithm: 2048-bit RSA key
Version: 3
Extensions:
#1: ObjectId: 2.5.29.35 Criticality=false
AuthorityKeyIdentifier [
KeyIdentifier [
0000: F3 F3 90 88 1F CE E7 96 3D FA B5 9B A8 6A EC 1F ........=....j..
0010: C1 07 CA 25 ...%
]
]
#2: ObjectId: 2.5.29.19 Criticality=false
BasicConstraints:[
CA:false
PathLen: undefined
]
#3: ObjectId: 2.5.29.17 Criticality=false
SubjectAlternativeName [
DNSName: localhost
IPAddress: 127.0.0.1
IPAddress: 0:0:0:0:0:0:0:1
]
#4: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: C5 06 BE D2 90 8A 39 2C F4 7D 96 FD C9 70 BF 82 ......9,.....p..
0010: A7 F0 AD 74 ...t
]
]
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.