简体   繁体   English

如何为 Spring 数据 Cassandra 配置 SSL 客户端

[英]How to configure SSL client for Spring Data Cassandra

The only option that I can find for configuring the SSL configuration is spring.data.cassandra.ssl=true/false .我能找到的用于配置 SSL 配置的唯一选项是spring.data.cassandra.ssl=true/false We need to configure a key store and trust store to enable two-way SSL between the client and the cluster.我们需要配置一个密钥库和信任库,以在客户端和集群之间启用双向 SSL。

Is this possible out of the box or do I need to configure the cluster manually with my own @Configuration object?这是开箱即用的,还是我需要使用我自己的@Configuration object 手动配置集群?

I just wrote everything in the application.properties file我只是在 application.properties 文件中写了所有内容

server.ssl.enabled=true
server.ssl.key-store=classpath:xyz.jks
server.ssl.key-store-password=xyz
server.ssl.key-store-type=JKS
server.ssl.key-alias=xyz

Create a bean CqlSessionBuilderCustomizer to populate SSL details.创建一个 bean CqlSessionBuilderCustomizer 来填充 SSL 详细信息。 Build your own SSLContext using truststore and keystore.使用信任库和密钥库构建您自己的 SSLContext。

  @Bean
  public CqlSessionBuilderCustomizer cqlSessionBuilderCustomizer() {
      return cqlSessionBuilder -> {
        try {
            cqlSessionBuilder
                      .withSslContext(buildContext());
        } catch (Exception e) {
            e.printStackTrace();
        }
    };

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM