org.sdase.commons.spring.boot.mongodb.MongoDbCaCertificatesConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sda-commons-starter-mongodb Show documentation
Show all versions of sda-commons-starter-mongodb Show documentation
A library to bootstrap services easily that follow the patterns and specifications promoted by the SDA SE
The newest version!
/*
* Copyright 2022- SDA SE Open Industry Solutions (https://www.sda.se)
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package org.sdase.commons.spring.boot.mongodb;
import javax.net.ssl.SSLContext;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.mongo.MongoClientSettingsBuilderCustomizer;
import org.springframework.context.annotation.Bean;
@AutoConfiguration
public class MongoDbCaCertificatesConfiguration {
@Bean
@ConditionalOnBean(SSLContext.class)
public MongoClientSettingsBuilderCustomizer sslMongoCustomizer(SSLContext sslContext) {
// enabling ssl will be exclusively done by the options in the connection
// string
return clientSettingsBuilder ->
clientSettingsBuilder.applyToSslSettings(builder -> builder.context(sslContext));
}
}