elastic Q&A(updating)

elasticsearch

版本7.16.2

java client

java client连接带基础安全ES

  URI uri = ElasticSearchClient.class.getClassLoader().getResource("http.p12").toURI();

  Path trustStorePath = Paths.get(uri);
  KeyStore truststore = KeyStore.getInstance("pkcs12");

  RestClientBuilder builder = null;

  try (InputStream is = Files.newInputStream(trustStorePath)) {
      truststore.load(is, "http123".toCharArray());

      SSLContextBuilder sslBuilder = SSLContexts.custom().loadTrustMaterial(truststore, null);
      SSLContext sslContext = sslBuilder.build();

      final CredentialsProvider credentialsProvider =
              new BasicCredentialsProvider();
      credentialsProvider.setCredentials(AuthScope.ANY,
              new UsernamePasswordCredentials("elastic", "password"));

      builder = RestClient.builder(
                      new HttpHost("hostname1", 9200, "https"),
                      new HttpHost("hostname2", 9200, "https"),
                      new HttpHost("hostname3", 9200, "https")
              )
              .setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
                  @Override
                  public HttpAsyncClientBuilder customizeHttpClient(
                          HttpAsyncClientBuilder httpClientBuilder) {
                      return httpClientBuilder
                              .setSSLContext(sslContext)
                              .setDefaultCredentialsProvider(credentialsProvider);
                  }
              });


  } catch (Exception e) {
      e.printStackTrace();
      throw new RuntimeException(e);
  }
  RestClient client = builder.build();

ElasticsearchSecurityException[failed to load SSL configuration [xpack.security.transport.ssl]]; nested: ElasticsearchException[failed to initialize SSL TrustManager]; nested: IOException[parseAlgParameters failed: ObjectIdentifier() -- data isn't an object ID (tag = 48)]; nested: IOException[ObjectIdentifier() -- data isn't an object ID (tag = 48)];

是由于ES集群jdk版本与开发jdk版本不同

kibana

配置基础安全kibana时出现hostname和 cert's CN匹配不上问题

[17:58:03.050] [error][elasticsearch-service] Unable to retrieve version information from Elasticsearch nodes. Hostname/IP does not match certificate's altnames: Host: sit-201-128-10-12-20-03. is not cert's CN: SIT-201-128-10-12-20-*

实际上配置文件

...
elasticsearch.hosts: "https://SIT-201-128-10-12-20-03:9200"
...

运行仍出来上边问题.

又测试直接通过命令修改
先注释配置文件中elasticsearch.hosts
再启动命令中传入

 bin/kibana -H SIT-201-128-10-12-20-03 -e 'https://SIT-201-128-10-12-20-03:9200'

结果仍出来如上错误. 实际上和在配置trino安全认证时遇到的类似问题一样,在生成CA相关操作时相关的hostname一定要小写,不然就会出现这样问题

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大怀特

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值