Thank you @stephenb for your response.
I ran the command in another remote machine and not on hostmachine which is why there is no info of certs. I have only edited the ip and host name.
Here is the command I used to create index and have attached the output as well:
curl POST -v -k "https: //elastic:password@hostmachine:9200/test-index-2/_doc" -d '{"foo" : "bar"}' -H "Content-Type: application/json"
Output:
* Rebuilt URL to: POST/
* Could not resolve host: POST
* Closing connection 0
curl: (6) Could not resolve host: POST
* Trying 10.35.135.175...
* TCP_NODELAY set
* Connected to hostmachine (10.35.135.175) port 9200 (#1)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-SHA
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: CN=hostmachine
* start date: Apr 2 07:34:47 2024 GMT
* expire date: Apr 2 07:34:47 2027 GMT
* issuer: CN=Elastic Certificate Tool Autogenerated CA
* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
* Server auth using Basic with user 'elastic'
> POST /test-index-2/_doc HTTP/1.1
> Host: hostmachine:9200
> Authorization: Basic ZWxhc3RpYzp6cjdZOHZXdkxXY3YzeDZFMmsxMw==
> User-Agent: curl/7.61.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 15
>
* upload completely sent off: 15 out of 15 bytes
< HTTP/1.1 201 Created
< Location: /test-index-2/_doc/18lfvI4Bo2uLaphFZqln
< Warning: 299 Elasticsearch-6.8.23-4f67856 "the default number of shards will change from [5] to [1] in 7.0.0; if you wish to continue using the default of [5] shards, you must manage this on the create index request or with an index template"
< content-type: application/json; charset=UTF-8
< content-length: 179
<
* Connection #1 to host hostmachine left intact
{"_index":"test-index-2","_type":"_doc","_id":"18lfvI4Bo2uLaphFZqln","_version":1,"result":"created","_shards":{"total":2,"successful":2,"failed":0},"_seq_no":0,"_primary_term":1}
It is able to create an index if the command is ran on host machine or any of the node machine but throws an error whenever ran from some other remote machine.
Also, please note that I am using self signed certificate generated by elasticsearch itself.