From 8e21ef95f326c6f7923983b9bb1291295916d313 Mon Sep 17 00:00:00 2001 From: gaoqr <13665037151@163.com> Date: Mon, 4 Nov 2024 10:42:06 +0800 Subject: [PATCH] =?UTF-8?q?es=E8=BF=9E=E6=8E=A5=E9=85=8D=E7=BD=AE=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=A4=96=E9=83=A8=E8=AF=81=E4=B9=A6=E3=80=81=E8=AF=81?= =?UTF-8?q?=E4=B9=A6=E5=AF=86=E7=A0=81=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChenfengElasticsearchAutoConfiguration.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cf-framework/cf-spring-boot-starter-elasticsearch/src/main/java/com/cf/imes/framework/es/config/ChenfengElasticsearchAutoConfiguration.java b/cf-framework/cf-spring-boot-starter-elasticsearch/src/main/java/com/cf/imes/framework/es/config/ChenfengElasticsearchAutoConfiguration.java index 4adfe55e4..b2ac94dcb 100644 --- a/cf-framework/cf-spring-boot-starter-elasticsearch/src/main/java/com/cf/imes/framework/es/config/ChenfengElasticsearchAutoConfiguration.java +++ b/cf-framework/cf-spring-boot-starter-elasticsearch/src/main/java/com/cf/imes/framework/es/config/ChenfengElasticsearchAutoConfiguration.java @@ -1,6 +1,6 @@ package com.cf.imes.framework.es.config; -import cn.hutool.core.io.FileUtil; +import cn.hutool.core.io.file.PathUtil; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.util.ObjectUtil; import co.elastic.clients.elasticsearch.ElasticsearchAsyncClient; @@ -146,7 +146,7 @@ public class ChenfengElasticsearchAutoConfiguration { } if (properties.isSecurityHttpSslEnable()) { // 开启ssl配置连接证书 - httpAsyncClientBuilder.setSSLContext(buildSSLContext(properties.getCertificatePath())).setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE); + httpAsyncClientBuilder.setSSLContext(buildSSLContext(properties)).setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE); } return httpAsyncClientBuilder; }; @@ -156,16 +156,16 @@ public class ChenfengElasticsearchAutoConfiguration { /** * 构建ssl请求信息 * - * @param certificatePath 证书地址 + * @param properties es配置 * @return */ - private SSLContext buildSSLContext(String certificatePath) { + private SSLContext buildSSLContext(EsProperties properties) { SSLContext sslContext = null; try { - Path trustStorePath = Paths.get(certificatePath); + Path trustStorePath = Paths.get(properties.getCertificatePath()); KeyStore trustStore = KeyStore.getInstance("pkcs12"); - try (InputStream is = FileUtil.getInputStream(trustStorePath)) { - trustStore.load(is, "elastic".toCharArray()); + try (InputStream is = PathUtil.getInputStream(trustStorePath)) { + trustStore.load(is, properties.getPassword().toCharArray()); } SSLContextBuilder sslContextBuilder = SSLContexts.custom() .loadTrustMaterial(trustStore, null);