ElasticSearch启用Xpack,配置ssl证书

文章目录

0, 证书过期的问题

  • 证书过期后,客户端或节点无法验证证书的有效性(如签名过期、信任锚失效),会触发 PKIX path validation failed或 CertificateExpiredException等错误,导致加密连接中断。此时,集群内部的节点认证(如传输层通信)和外部客户端的访问(如 HTTP 请求)均会失败
  • 证书过期后,因为启用Xpack后,集群节点之间通过 TLS/SSL加密进行数据同步(如主分片选举、副本复制),导致节点无法通过其他节点的身份验证,会被视为"不可信",导致节点脱离集群(掉节点)。严重时会引发集群分裂(Split Brain),影响数据的完整性和可用性
  • 证书过期后,ES master节点频繁添加、移除data节点,导致数据不可用,用户认证失败

1,生成ssl证书

bash 复制代码
#1,生成ca证书
[root@es1 elasticsearch]# ./bin/elasticsearch-certutil ca
This tool assists you in the generation of X.509 certificates and certificate
signing requests for use with SSL/TLS in the Elastic stack.
...
Please enter the desired output file [elastic-stack-ca.p12]: es-ca.p12
Enter password for es-ca.p12 : 

[root@es1 elasticsearch]# ll
total 664
drwxr-xr-x  2 znyw znyw   4096 Aug  4  2023 bin
drwxr-xr-x  3 znyw znyw    272 Jul 25 09:41 config
-rw-------  1 root root   2672 Sep 28 10:09 es-ca.p12
...

#2,根据ca,生成客户端cert证书
#证书有效期:默认3年,可指定有效期为100年=36500天
#                         ./bin/elasticsearch-certutil cert --ca es-ca.p12  --ca-pass '123456'  --pass '123456'  --days 36500
[root@es1 elasticsearch]# ./bin/elasticsearch-certutil cert --ca es-ca.p12  #
This tool assists you in the generation of X.509 certificates and certificate
...
Enter password for CA (es-ca.p12) : 
Please enter the desired output file [elastic-certificates.p12]: es-cert.p12         
Enter password for es-cert.p12 : 
Certificates written to /opt/elasticsearch/es-cert.p12

[root@es1 elasticsearch]# ll
total 668
drwxr-xr-x  2 znyw znyw   4096 Aug  4  2023 bin
drwxr-xr-x  3 znyw znyw    272 Jul 25 09:41 config
-rw-------  1 root root   2672 Sep 28 10:09 es-ca.p12
-rw-------  1 root root   3596 Sep 28 10:10 es-cert.p12
...

#3,查看客户端cert证书有效期
[root@es1 elasticsearch]# openssl pkcs12 -in es-cert.p12 -nokeys --password pass:'123456' |openssl x509 -enddate -noout 
notAfter=Sep 27 02:10:49 2028 GMT


#4,分发客户端cert证书到各ES节点

2,配置ES使用ssl证书

bash 复制代码
#5,配置ES,启用Xpack,使用该客户端cert证书
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.monitoring.collection.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: /opt/selasticsearch/es-cert.p12
xpack.security.transport.ssl.truststore.path: /opt/selasticsearch/es-cert.p12

#6,重启所有es节点,先重启master,再重启data

#7,通过ES接口,验证证书有效期
GET _ssl/certificates
[
  {
    "path" : "/opt/elasticsearch/config/es-cert.p12",
    "format" : "PKCS12",
    "alias" : "instance",
    "subject_dn" : "CN=instance",
    "serial_number" : "99147c0f3486f356bae9873b873ad57f2f79f3cb",
    "has_private_key" : true,
    "expiry" : "2028-08-27T02:10:49.000Z"
  },
....
相关推荐
Elastic 中国社区官方博客2 小时前
跳过有状态的 OTel Collector:Elasticsearch 9.5 原生存储两种指标时间类型
大数据·人工智能·elasticsearch·搜索引擎·重构·全文检索
PC2005-cloud1 天前
Elasticsearch 学习笔记:集群实战(3 控制节点 + 3 数据节点部署与故障转移)
笔记·学习·elasticsearch
Devin~Y1 天前
从内容社区到AI智能客服:Spring Boot + Spring Cloud + Spring AI 全栈实战面试拆解
java·spring boot·redis·elasticsearch·spring cloud·kafka·mybatis
凤山老林1 天前
复杂检索引擎落地:Spring Boot + Elasticsearch 数据同步与高阶查询实战
spring boot·后端·elasticsearch
Elastic 中国社区官方博客2 天前
你的 AI agent 不需要你的 API 密钥:使用 OAuth 2.1 对 Elasticsearch MCP 服务器进行身份验证
大数据·运维·人工智能·elasticsearch·搜索引擎·全文检索
互联网中的一颗神经元2 天前
ZZ — Git 速查表
大数据·git·elasticsearch
Elasticsearch2 天前
跳过有状态的 OTel Collector:Elasticsearch 9.5 原生存储两种指标时间类型
elasticsearch
C++、Java和Python的菜鸟3 天前
第2章 项目前置课-代码版本控制Git
大数据·elasticsearch·搜索引擎
Elasticsearch3 天前
什么是混合搜索?
elasticsearch
Elastic 中国社区官方博客3 天前
训练量仅占 0.35%,竞争力却达到 100%:jina-embeddings-v5-omni 背后的冻结塔架构
大数据·人工智能·elasticsearch·机器学习·重构·全文检索·jina