简体   繁体   中英

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 . We need to configure a key store and trust store to enable two-way SSL between the client and the cluster.

Is this possible out of the box or do I need to configure the cluster manually with my own @Configuration object?

I just wrote everything in the application.properties file

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. Build your own SSLContext using truststore and keystore.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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