Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] https connection using Spring Boot SSL Bundle #396

Open
aivish opened this issue Dec 17, 2024 · 0 comments
Open

[FEATURE] https connection using Spring Boot SSL Bundle #396

aivish opened this issue Dec 17, 2024 · 0 comments
Labels
enhancement New feature or request untriaged

Comments

@aivish
Copy link

aivish commented Dec 17, 2024

Is your feature request related to a problem?

When connecting to OpenSearch via https it would be nice to configure in properties which SSL Bundle to use. There already seem to be some properties for this:

opensearch:
  uris: https://opensearch-host:9200
  restclient:
    ssl:
      bundle: example

spring:
  ssl:
    bundle:
      pem:
        example:
          truststore:
            certificate: file:/path/to/opensearch.ca

But unless I'm doing something wrong the bundle is not used, maybe those properties are just there because OpenSearchProperties uses Restclient properties from Elasticsearch.

For this configuration to work I had to create custom RestClientBuilderCustomizer with something like this:

@Override
public void customize(HttpAsyncClientBuilder builder) {
    String sslBundleName = properties.getRestclient().getSsl().getBundle();
    if (StringUtils.hasText(sslBundleName)) {
        SslBundle sslBundle = sslBundles.getBundle(sslBundleName);
        SSLContext sslcontext = sslBundle.createSslContext();
        SslOptions sslOptions = sslBundle.getOptions();

        builder.setSSLContext(sslcontext);
        builder.setSSLStrategy(new SSLIOSessionStrategy(sslcontext, sslOptions.getEnabledProtocols(), sslOptions.getCiphers(), (HostnameVerifier) null));
    }
}

Maybe this should be part of OpenSearchRestClientConfigurations, applied by the DefaultRestClientBuilderCustomizer or set as part of opensearchRestClientBuilder? Elasticsearch autoconfiguration is doing something similar here - https://github.com/spring-projects/spring-boot/blob/v3.4.0/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientConfigurations.java#L97.

What solution would you like?

Configure opensearch.restclient.ssl.bundle without needing to create any additional RestClientBuilderCustomizer's .

What alternatives have you considered?

Create RestClientBuilderCustomizer or add my OpenSearch CA to global trust store (probably would work, but didn't try, don't really want to do that).

Do you have any additional context?

If this makes sense and looks reasonable I can try creating PR for this.

@aivish aivish added enhancement New feature or request untriaged labels Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request untriaged
Projects
None yet
Development

No branches or pull requests

1 participant