# What's the cause of the error and how to fix it?

**URL:** <https://discuss.elastic.co/t/whats-the-cause-of-the-error-and-how-to-fix-it/310480>\
**Category:** Elasticsearch\
**Created:** [July 24, 2022, 1:02pm UTC](https://discuss.elastic.co/t/whats-the-cause-of-the-error-and-how-to-fix-it/310480 "2022-07-24T13:02:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Firas\_Bougrine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/firas_bougrine/32/103349_2.png) [@Firas\_Bougrine](https://discuss.elastic.co/u/Firas_Bougrine)\
**Post date:** [July 24, 2022, 1:02pm UTC](https://discuss.elastic.co/t/whats-the-cause-of-the-error-and-how-to-fix-it/310480/1 "2022-07-24T13:02:35Z")

</div>

when i try to create a token for kibana :::

```auto
elkfiras@elkfiras:/usr/share/elasticsearch/bin$ sudo ./elasticsearch-create-enrollment-token -s kibana
[sudo] password for elkfiras:
12:57:33.755 [main] WARN org.elasticsearch.common.ssl.DiagnosticTrustManager - failed to establish trust with server at [192.168.37.2]; the server provided a certificate with subject name [CN=elkfiras], fingerprint [d97cb7ed2fc40a1a5534399b11121c233879c76f], no keyUsage and extendedKeyUsage [serverAuth]; the session uses cipher suite [TLS_AES_256_GCM_SHA384] and protocol [TLSv1.3]; the certificate has subject alternative names [DNS:localhost,IP:192.168.1.17,DNS:elkfiras,IP:0:0:0:0:0:0:0:1,IP:127.0.0.1,IP:fe80:0:0:0:20c:29ff:fe65:82ff]; the certificate is issued by [CN=Elasticsearch security auto-configuration HTTP CA]; the certificate is signed by (subject [CN=Elasticsearch security auto-configuration HTTP CA] fingerprint [e9548ce60b383fa3491a7bdd69771e437ba0a4de] {trusted issuer}) which is self-issued; the [CN=Elasticsearch security auto-configuration HTTP CA] certificate is trusted in this ssl context ([xpack.security.http.ssl (with trust configuration: Composite-Trust{JDK-trusted-certs,StoreTrustConfig{path=certs/http.p12, password=<non-empty>, type=PKCS12, algorithm=PKIX}})])
java.security.cert.CertificateException: No subject alternative names matching IP address 192.168.37.2 found
        at sun.security.util.HostnameChecker.matchIP(HostnameChecker.java:165) ~[?:?]
        at sun.security.util.HostnameChecker.match(HostnameChecker.java:101) ~[?:?]
        at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:452) ~[?:?]
        at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:426) ~[?:?]
        at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:238) ~[?:?]
        at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:132) ~[?:?]
        at org.elasticsearch.common.ssl.DiagnosticTrustManager.checkServerTrusted(DiagnosticTrustManager.java:82) ~[?:?]
        at sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1335) ~[?:?]
        at sun.security.ssl.CertificateMessage$T13CertificateConsumer.onConsumeCertificate(CertificateMessage.java:1226) ~[?:?]
        at sun.security.ssl.CertificateMessage$T13CertificateConsumer.consume(CertificateMessage.java:1169) ~[?:?]
        at sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396) ~[?:?]
        at sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:480) ~[?:?]
        at sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:458) ~[?:?]
        at sun.security.ssl.TransportContext.dispatch(TransportContext.java:201) ~[?:?]
        at sun.security.ssl.SSLTransport.decode(SSLTransport.java:172) ~[?:?]
        at sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1500) ~[?:?]
        at sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1415) ~[?:?]
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:450) ~[?:?]
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:421) ~[?:?]
        at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:578) ~[?:?]
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183) ~[?:?]
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:142) ~[?:?]
        at org.elasticsearch.xpack.core.common.socket.SocketAccess.lambda$doPrivileged$0(SocketAccess.java:42) ~[?:?]
        at java.security.AccessController.doPrivileged(AccessController.java:569) [?:?]
        at org.elasticsearch.xpack.core.common.socket.SocketAccess.doPrivileged(SocketAccess.java:41) [x-pack-core-8.3.1.jar:8.3.1]
        at org.elasticsearch.xpack.core.security.CommandLineHttpClient.execute(CommandLineHttpClient.java:178) [x-pack-core-8.3.1.jar:8.3.1]
        at org.elasticsearch.xpack.core.security.CommandLineHttpClient.execute(CommandLineHttpClient.java:112) [x-pack-core-8.3.1.jar:8.3.1]
        at org.elasticsearch.xpack.security.tool.BaseRunAsSuperuserCommand.checkClusterHealthWithRetries(BaseRunAsSuperuserCommand.java:214) [x-pack-security-8.3.1.jar:8.3.1]
        at org.elasticsearch.xpack.security.tool.BaseRunAsSuperuserCommand.execute(BaseRunAsSuperuserCommand.java:127) [x-pack-security-8.3.1.jar:8.3.1]
        at org.elasticsearch.common.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:54) [elasticsearch-8.3.1.jar:8.3.1]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:85) [elasticsearch-cli-8.3.1.jar:8.3.1]
        at org.elasticsearch.cli.Command.main(Command.java:50) [elasticsearch-cli-8.3.1.jar:8.3.1]
        at org.elasticsearch.launcher.CliToolLauncher.main(CliToolLauncher.java:64) [cli-launcher-8.3.1.jar:8.3.1]

ERROR: Failed to determine the health of the cluster.

```

---

<div class="post-metadata">

**Author:** ![BenB196](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benb196/32/83401_2.png) [@BenB196](https://discuss.elastic.co/u/BenB196)\
**Post date:** [July 24, 2022, 3:46pm UTC](https://discuss.elastic.co/t/whats-the-cause-of-the-error-and-how-to-fix-it/310480/2 "2022-07-24T15:46:14Z")

</div>

This error is caused by the `elasticsearch-create-enrollment-token` process not knowing that what it is connecting to is using HTTPS, try setting the `--url` parameter as mentioned: [elasticsearch-create-enrollment-token | Elasticsearch Guide [8.3] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/8.3/create-enrollment-token.html#create-enrollment-token-parameters)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 21, 2022, 3:46pm UTC](https://discuss.elastic.co/t/whats-the-cause-of-the-error-and-how-to-fix-it/310480/3 "2022-08-21T15:46:31Z")

</div>

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