From 35c750d4acad65e1bbf306b98967334c234d9de4 Mon Sep 17 00:00:00 2001 From: xiongxiaoyang <1179705413@qq.com> Date: Tue, 4 Apr 2023 01:03:34 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E9=80=9A=E8=BF=87=20`spring.elasticsea?= =?UTF-8?q?rch.ssl.verification-mode`=20=E9=85=8D=E7=BD=AE=E9=A1=B9?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=20ssl=20=E7=9A=84=E8=AE=A4=E8=AF=81=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit none:不认证,信任所有的证书 --- .../java/io/github/xxyopen/novel/search/config/EsConfig.java | 2 ++ novel-search/src/main/resources/application.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/novel-search/src/main/java/io/github/xxyopen/novel/search/config/EsConfig.java b/novel-search/src/main/java/io/github/xxyopen/novel/search/config/EsConfig.java index 1c5dba7..1998dcd 100644 --- a/novel-search/src/main/java/io/github/xxyopen/novel/search/config/EsConfig.java +++ b/novel-search/src/main/java/io/github/xxyopen/novel/search/config/EsConfig.java @@ -6,6 +6,7 @@ import org.apache.http.impl.nio.client.HttpAsyncClientBuilder; import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClientBuilder; import org.springframework.beans.factory.ObjectProvider; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.elasticsearch.RestClientBuilderCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -40,6 +41,7 @@ public class EsConfig { * fix `sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: * unable to find valid certification path to requested target` */ + @ConditionalOnProperty(value = "spring.elasticsearch.ssl.verification-mode",havingValue = "none") @Bean RestClient elasticsearchRestClient(RestClientBuilder restClientBuilder, ObjectProvider builderCustomizers) { diff --git a/novel-search/src/main/resources/application.yml b/novel-search/src/main/resources/application.yml index 75b5740..2c8d9ad 100644 --- a/novel-search/src/main/resources/application.yml +++ b/novel-search/src/main/resources/application.yml @@ -9,6 +9,8 @@ spring: - https://127.0.0.1:9200 username: elastic password: Fy2JWjJ1hcO2mi1USFLR +# ssl: +# verification-mode: none # XXL-JOB 配置 xxl: