perf: 通过 spring.elasticsearch.ssl.verification-mode 配置项设置 ssl 的认证模式

none:不认证,信任所有的证书
This commit is contained in:
xiongxiaoyang 2023-04-04 01:03:34 +08:00
parent 58b0666214
commit 35c750d4ac
2 changed files with 4 additions and 0 deletions

View File

@ -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<RestClientBuilderCustomizer> builderCustomizers) {

View File

@ -9,6 +9,8 @@ spring:
- https://127.0.0.1:9200
username: elastic
password: Fy2JWjJ1hcO2mi1USFLR
# ssl:
# verification-mode: none
# XXL-JOB 配置
xxl: