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);