You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "kezhenxu94 (via GitHub)" <gi...@apache.org> on 2025/12/30 11:00:18 UTC

[PR] feat: support open search client cert auth [skywalking]

kezhenxu94 opened a new pull request, #13641:
URL: https://github.com/apache/skywalking/pull/13641

   <!--
       ⚠️ Please make sure to read this template first, pull requests that don't accord with this template
       maybe closed without notice.
       Texts surrounded by `<` and `>` are meant to be replaced by you, e.g. <framework name>, <issue number>.
       Put an `x` in the `[ ]` to mark the item as CHECKED. `[x]`
   -->
   
   <!-- ==== 🐛 Remove this line WHEN AND ONLY WHEN you're fixing a bug, follow the checklist 👇 ====
   ### Fix <bug description or the bug issue number or bug issue link>
   - [ ] Add a unit test to verify that the fix works.
   - [ ] Explain briefly why the bug exists and how to fix it.
        ==== 🐛 Remove this line WHEN AND ONLY WHEN you're fixing a bug, follow the checklist 👆 ==== -->
   
   <!-- ==== 📈 Remove this line WHEN AND ONLY WHEN you're improving the performance, follow the checklist 👇 ====
   ### Improve the performance of <class or module or ...>
   - [ ] Add a benchmark for the improvement, refer to [the existing ones](https://github.com/apache/skywalking/blob/master/apm-commons/apm-datacarrier/src/test/java/org/apache/skywalking/apm/commons/datacarrier/LinkedArrayBenchmark.java)
   - [ ] The benchmark result.
   ```text
   <Paste the benchmark results here>
   ```
   - [ ] Links/URLs to the theory proof or discussion articles/blogs. <links/URLs here>
        ==== 📈 Remove this line WHEN AND ONLY WHEN you're improving the performance, follow the checklist 👆 ==== -->
   
   <!-- ==== 🆕 Remove this line WHEN AND ONLY WHEN you're adding a new feature, follow the checklist 👇 ====
   ### <Feature description>
   - [ ] If this is non-trivial feature, paste the links/URLs to the design doc.
   - [ ] Update the documentation to include this new feature.
   - [ ] Tests(including UT, IT, E2E) are added to verify the new feature.
   - [ ] If it's UI related, attach the screenshots below.
        ==== 🆕 Remove this line WHEN AND ONLY WHEN you're adding a new feature, follow the checklist 👆 ==== -->
   
   - [ ] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #<issue number>.
   - [ ] Update the [`CHANGES` log](https://github.com/apache/skywalking/blob/master/docs/en/changes/changes.md).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: support opensearch client cert auth [skywalking]

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng merged PR #13641:
URL: https://github.com/apache/skywalking/pull/13641


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: support open search client cert auth [skywalking]

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #13641:
URL: https://github.com/apache/skywalking/pull/13641#discussion_r2660484290


##########
docs/en/setup/backend/storages/elasticsearch.md:
##########
@@ -11,7 +11,7 @@ In order to activate OpenSearch as storage, set the storage provider to **elasti
 
 We support and tested the following versions of OpenSearch:
 
-- 1.1.0, 1.3.10
+- 1.3.10

Review Comment:
   Do we remove the support of 1.1.0, or just because of not been tested?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: support open search client cert auth [skywalking]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #13641:
URL: https://github.com/apache/skywalking/pull/13641#discussion_r2659696838


##########
oap-server/server-starter/src/main/resources/application.yml:
##########
@@ -160,6 +160,8 @@ storage:
     password: ${SW_ES_PASSWORD:""}
     trustStorePath: ${SW_STORAGE_ES_SSL_JKS_PATH:""}
     trustStorePass: ${SW_STORAGE_ES_SSL_JKS_PASS:""}
+    keyStorePath: ${SW_STORAGE_ES_SSL_KEY_STORE_PATH:""} # Path to client certificate keystore for mutual TLS (OpenSearch/Elasticsearch client cert auth). Supports PKCS12 (.p12, .pfx) and JKS (.jks) formats.
+    keyStorePass: ${SW_STORAGE_ES_SSL_KEY_STORE_PASS:""} # Password for the client certificate keystore. Can be managed via secretsManagementFile.
     secretsManagementFile: ${SW_ES_SECRETS_MANAGEMENT_FILE:""} # Secrets management file in the properties format includes the username, password, which are managed by 3rd party tool.

Review Comment:
   The new keyStorePath and keyStorePass configuration options for client certificate authentication are not documented. The existing elasticsearch.md documentation covers trustStorePath but does not include the new mutual TLS configuration options. Users need documentation explaining how to configure client certificate authentication for OpenSearch/Elasticsearch.
   ```suggestion
       trustStorePath: ${SW_STORAGE_ES_SSL_JKS_PATH:""} # Path to the truststore that contains CA certificates used to verify the OpenSearch/Elasticsearch server certificate.
       trustStorePass: ${SW_STORAGE_ES_SSL_JKS_PASS:""} # Password for the truststore defined in trustStorePath.
       keyStorePath: ${SW_STORAGE_ES_SSL_KEY_STORE_PATH:""} # Path to the client certificate keystore for mutual TLS (OpenSearch/Elasticsearch client certificate authentication). Supports PKCS12 (.p12, .pfx) and JKS (.jks) formats.
       keyStorePass: ${SW_STORAGE_ES_SSL_KEY_STORE_PASS:""} # Password for the client certificate keystore defined in keyStorePath. This can be externalized via secretsManagementFile.
       secretsManagementFile: ${SW_ES_SECRETS_MANAGEMENT_FILE:""} # Secrets management file in properties format (e.g. username, password, keystore passwords) managed by a 3rd party tool.
   ```



##########
oap-server/server-library/library-elasticsearch-client/src/main/java/org/apache/skywalking/library/elasticsearch/ElasticSearchBuilder.java:
##########
@@ -116,6 +126,18 @@ public ElasticSearchBuilder trustStorePass(String trustStorePass) {
         return this;
     }
 
+    public ElasticSearchBuilder keyStorePath(String keyStorePath) {
+        requireNonNull(keyStorePath, "keyStorePath");
+        this.keyStorePath = keyStorePath;
+        return this;
+    }
+
+    public ElasticSearchBuilder keyStorePass(String keyStorePass) {
+        requireNonNull(keyStorePass, "keyStorePass");
+        this.keyStorePass = keyStorePass;
+        return this;
+    }

Review Comment:
   The keyStorePass and trustStorePass builder methods use requireNonNull which prevents passing null values. However, in ElasticSearchClient.connect(), the code checks if these values are null before calling the builder methods. This inconsistency could cause issues if someone tries to set an empty password. The builder should allow null values and handle password-less keystores, or the validation logic should be consistent throughout.



##########
oap-server/server-library/library-elasticsearch-client/src/main/java/org/apache/skywalking/library/elasticsearch/ElasticSearchBuilder.java:
##########
@@ -157,19 +179,62 @@ public ElasticSearch build() {
                          .connectTimeout(connectTimeout)
                          .idleTimeout(socketTimeout)
                          .useHttp2Preface(false)
-                         .workerGroup(numHttpClientThread > 0 ? numHttpClientThread : NUM_PROC);
-
-        if (StringUtil.isNotBlank(trustStorePath)) {
-            final TrustManagerFactory trustManagerFactory =
-                TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
-            final KeyStore truststore = KeyStore.getInstance("jks");
-            try (final InputStream is = Files.newInputStream(Paths.get(trustStorePath))) {
-                truststore.load(is, trustStorePass.toCharArray());
-            }
-            trustManagerFactory.init(truststore);
-
-            factoryBuilder.tlsCustomizer(
-                sslContextBuilder -> sslContextBuilder.trustManager(trustManagerFactory));
+                         .workerGroup(new NioEventLoopGroup(numHttpClientThread > 0 ? numHttpClientThread : NUM_PROC), true);

Review Comment:
   The workerGroup is now instantiated with a new NioEventLoopGroup and set to shutdown on close (second parameter true). However, the previous implementation used the integer value directly. This change means that every ElasticSearch client instance will create its own event loop group, which could lead to resource exhaustion if multiple clients are created. Consider whether this EventLoopGroup should be shared across clients or if there's proper lifecycle management to prevent resource leaks.



##########
test/e2e-v2/cases/storage/opensearch/docker-compose.yml:
##########
@@ -42,15 +107,24 @@ services:
       SW_STORAGE: elasticsearch
       SW_STORAGE_ES_CLUSTER_NODES: opensearch:9200
       SW_ES_USER: admin
-      SW_ES_PASSWORD: admin
+      SW_ES_PASSWORD: SecurePass@2024!
+      SW_STORAGE_ES_HTTP_PROTOCOL: https
+      SW_STORAGE_ES_SSL_JKS_PATH: /etc/skywalking/certs/truststore.jks
+      SW_STORAGE_ES_SSL_JKS_PASS: changeit
+      SW_STORAGE_ES_SSL_KEY_STORE_PATH: /etc/skywalking/certs/client.p12
+      SW_STORAGE_ES_SSL_KEY_STORE_PASS: changeit
+      JAVA_OPTS: -Dcom.linecorp.armeria.useEpoll=false # TODO: fix this

Review Comment:
   This TODO comment indicates an incomplete fix for an Armeria epoll issue. While TODOs in test configuration are acceptable if tracked, this should reference a corresponding issue number or have a plan for resolution to ensure it doesn't remain indefinitely.
   ```suggestion
         JAVA_OPTS: -Dcom.linecorp.armeria.useEpoll=false # Epoll disabled in e2e tests due to known instability on some hosts
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: support open search client cert auth [skywalking]

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #13641:
URL: https://github.com/apache/skywalking/pull/13641#issuecomment-3708139699

   Please update the elastic/opensearch storage docs about how to use different auth in different servers.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: support open search client cert auth [skywalking]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #13641:
URL: https://github.com/apache/skywalking/pull/13641#discussion_r2660199866


##########
test/e2e-v2/cases/storage/opensearch/generate-certs.sh:
##########
@@ -0,0 +1,88 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e
+
+CERTS_DIR="./certs"
+mkdir -p "$CERTS_DIR"
+
+# Generate Root CA
+openssl genrsa -out "$CERTS_DIR/root-ca-key.pem" 2048
+openssl req -new -x509 -sha256 -key "$CERTS_DIR/root-ca-key.pem" \
+  -subj "/C=US/ST=CA/L=Test/O=SkyWalking/OU=Test/CN=SkyWalking Root CA" \
+  -out "$CERTS_DIR/root-ca.pem" -days 730
+
+# Generate Node Certificate
+openssl genrsa -out "$CERTS_DIR/node-key.pem" 2048
+openssl req -new -key "$CERTS_DIR/node-key.pem" \
+  -subj "/C=US/ST=CA/L=Test/O=SkyWalking/OU=Test/CN=opensearch" \
+  -out "$CERTS_DIR/node.csr"
+
+# Create SAN config for node cert
+cat >"$CERTS_DIR/node-san.cnf" <<EOFSAN
+[req]
+distinguished_name = req_distinguished_name
+req_extensions = v3_req
+
+[req_distinguished_name]
+
+[v3_req]
+subjectAltName = @alt_names
+
+[alt_names]
+DNS.1 = opensearch
+DNS.2 = localhost
+IP.1 = 127.0.0.1
+EOFSAN
+
+openssl x509 -req -in "$CERTS_DIR/node.csr" \
+  -CA "$CERTS_DIR/root-ca.pem" -CAkey "$CERTS_DIR/root-ca-key.pem" -CAcreateserial \
+  -out "$CERTS_DIR/node.pem" -days 730 -sha256 \
+  -extfile "$CERTS_DIR/node-san.cnf" -extensions v3_req
+
+# Generate Admin Certificate (for securityadmin tool)
+openssl genrsa -out "$CERTS_DIR/admin-key.pem" 2048
+openssl req -new -key "$CERTS_DIR/admin-key.pem" \
+  -subj "/C=US/ST=CA/L=Test/O=SkyWalking/OU=Test/CN=admin" \
+  -out "$CERTS_DIR/admin.csr"
+openssl x509 -req -in "$CERTS_DIR/admin.csr" \
+  -CA "$CERTS_DIR/root-ca.pem" -CAkey "$CERTS_DIR/root-ca-key.pem" -CAcreateserial \
+  -out "$CERTS_DIR/admin.pem" -days 730 -sha256
+
+# Generate Client Certificate (for SkyWalking OAP)
+# CN must match the username in roles_mapping (node-0.example.com)
+openssl genrsa -out "$CERTS_DIR/client-key.pem" 2048
+openssl req -new -key "$CERTS_DIR/client-key.pem" \
+  -subj "/C=US/ST=CA/L=Test/O=SkyWalking/OU=Test/CN=node-0.example.com" \
+  -out "$CERTS_DIR/client.csr"
+openssl x509 -req -in "$CERTS_DIR/client.csr" \
+  -CA "$CERTS_DIR/root-ca.pem" -CAkey "$CERTS_DIR/root-ca-key.pem" -CAcreateserial \
+  -out "$CERTS_DIR/client.pem" -days 730 -sha256
+
+# Create PKCS12 keystore for client (for Java applications)
+openssl pkcs12 -export -in "$CERTS_DIR/client.pem" -inkey "$CERTS_DIR/client-key.pem" \
+  -out "$CERTS_DIR/client.p12" -name "node-0.example.com" -passout pass:changeit
+
+# Create JKS truststore with root CA (remove existing if present)

Review Comment:
   The hardcoded password "changeit" is used for both the client keystore and truststore. While this is acceptable for test environments, consider adding a comment warning that this is a test-only value and should never be used in production environments. This helps prevent developers from accidentally copying this configuration to production systems.
   ```suggestion
   # Create PKCS12 keystore for client (for Java applications)
   # NOTE: The hardcoded password "changeit" below is for test/e2e use only and MUST NOT be used in production.
   openssl pkcs12 -export -in "$CERTS_DIR/client.pem" -inkey "$CERTS_DIR/client-key.pem" \
     -out "$CERTS_DIR/client.p12" -name "node-0.example.com" -passout pass:changeit
   
   # Create JKS truststore with root CA (remove existing if present)
   # NOTE: The hardcoded password "changeit" below is for test/e2e use only and MUST NOT be used in production.
   ```



##########
test/e2e-v2/cases/storage/opensearch/docker-compose.yml:
##########
@@ -42,15 +107,23 @@ services:
       SW_STORAGE: elasticsearch
       SW_STORAGE_ES_CLUSTER_NODES: opensearch:9200
       SW_ES_USER: admin

Review Comment:
   The hardcoded password "SecurePass@2024!" is visible in the docker-compose configuration. While this is acceptable for E2E test environments, consider adding a comment indicating this is for testing purposes only. This helps prevent security misconfigurations if this file is used as a template.
   ```suggestion
         SW_ES_USER: admin
         # Test-only password for E2E environment; do not use this value in production.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: support open search client cert auth [skywalking]

Posted by "kezhenxu94 (via GitHub)" <gi...@apache.org>.
kezhenxu94 commented on code in PR #13641:
URL: https://github.com/apache/skywalking/pull/13641#discussion_r2660557352


##########
docs/en/setup/backend/storages/elasticsearch.md:
##########
@@ -11,7 +11,7 @@ In order to activate OpenSearch as storage, set the storage provider to **elasti
 
 We support and tested the following versions of OpenSearch:
 
-- 1.1.0, 1.3.10
+- 1.3.10

Review Comment:
   > Do we remove the support of 1.1.0, or just because of not been tested?
   
   We just remove it from the test matrix



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org