hi,
I generated a CA certificate using:
./elasticsearch-certutil ca --pem --out /certs/ca.zip
and then generated a cert using:
./bin/elasticsearch-certutil cert \
--out /var/snap/amazon-ssm-agent/7628/elasticsearch-8.11.2/config/certs/elastic.zip \
--name elastic \
--ca-cert /var/snap/amazon-ssm-agent/7628/elasticsearch-8.11.2/config/certs/ca/ca/ca.crt \
--ca-key /var/snap/amazon-ssm-agent/7628/elasticsearch-8.11.2/config/certs/ca/ca/ca.key \
--dns elastic-cluster.mydomain.com \
--pem
my current elasticsearch config is:
# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
enabled: true
certificate: certs/elastic/elastic.crt
key: certs/elastic/elastic.key
certificate_authorities: certs/ca/ca/ca.crt
#keystore.path: certs/http.p12
# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:
enabled: true
verification_mode: certificate
keystore.path: certs/transport.p12
truststore.path: certs/transport.p12
# Create a new cluster with the current node only
# Additional nodes can still join the cluster later
cluster.initial_master_nodes: ["ip-10-11-9-43"]
# Allow HTTP API connections from anywhere
# Connections are encrypted and require user authentication
http.host: 0.0.0.0
when I run:
curl -X GET -u user:password https://elastic-cluster.mydomain.com:9200/ --cacert /var/snap/amazon-ssm-agent/7628/elasticsearch-8.11.2/config/certs/ca/ca/ca.crt
it works, now I need to implemented with js code, then I generate caFingerprint using:
openssl x509 -fingerprint -sha256 -noout -in /var/snap/amazon-ssm-agent/7628/elasticsearch-8.11.2/config/certs/ca/ca/ca.crt
it returns:
"61:C2:4E:2B:5A:8A:F4:A5:DA:23:62:A8:E8:01:50:2B:9E:A6:31:61:2A:7B:BC:70:A3:1D:CF:45:89:81:37:31"
but when I implement my code as follow:
const client = new Client({
node: "https://elastic-cluster.mydomain.com:9200",
auth: {
username: "user",
password: "password",
},
// the fingerprint (SHA256) of the CA certificate that is used to sign
// the certificate that the Elasticsearch node presents for TLS.
caFingerprint: "61:C2:4E:2B:5A:8A:F4:A5:DA:23:62:A8:E8:01:50:2B:9E:A6:31:61:2A:7B:BC:70:A3:1D:CF:45:89:81:37:31",
tls: {
// might be required if it's a self-signed certificate
rejectUnauthorized: false,
},
});
returns error:
(node:23052) UnhandledPromiseRejectionWarning: ConnectionError: Invalid or malformed certificate
at SniffingTransport.request (/var/www/serverless/node_modules/@elastic/transport/lib/Transport.js:541:31)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Cat.indices (/var/www/serverless/node_modules/@elastic/elasticsearch/lib/api/api/cat.js:221:16)
at async /var/www/serverless/elastic.js:28:17
Condiser it worked with http_ca.crt caFingerPrint generated before I change the elasticsearch.yml using new ca and certs, but now that http_ca.crt fingerPrint doesnt work anymore
I tried using Fingerprint generated with http_ca.crt - ca.crt - elastic.crt. None works actually