You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/features/dev-services.adoc
+86
Original file line number
Diff line number
Diff line change
@@ -137,6 +137,92 @@ The following service connections are currently supported:
137
137
138
138
139
139
140
+
[[features.dev-services.docker-compose.ssl]]
141
+
=== SSL support
142
+
143
+
Some images come with SSL enabled out of the box, or maybe you want to enable SSL for the container to mirror your production setup.
144
+
Spring Boot supports SSL configuration for supported service connections.
145
+
Please note that you still have to enable SSL on the service which is running inside the container yourself, this feature only configures SSL on the client side in your application.
146
+
147
+
SSL is supported for the following service connections:
148
+
149
+
* Cassandra
150
+
* Couchbase
151
+
* Elasticsearch
152
+
* Kafka
153
+
* MongoDB
154
+
* RabbitMQ
155
+
* Redis
156
+
157
+
To enable SSL support for a service, you can use https://docs.docker.com/reference/compose-file/services/#labels[service labels].
158
+
159
+
For JKS based keystores and truststores, you can use the following container labels:
You can use the javadoc:org.springframework.boot.testcontainers.service.connection.Ssl[format=annotation], javadoc:org.springframework.boot.testcontainers.service.connection.JksKeyStore[format=annotation], javadoc:org.springframework.boot.testcontainers.service.connection.JksTrustStore[format=annotation], javadoc:org.springframework.boot.testcontainers.service.connection.PemKeyStore[format=annotation] and javadoc:org.springframework.boot.testcontainers.service.connection.PemTrustStore[format=annotation] annotations on a supported container to enable SSL support for that service connection.
129
+
Please note that you still have to enable SSL on the service which is running inside the Testcontainer yourself, the annotations only configure SSL on the client side in your application.
130
+
131
+
include-code::MyRedisWithSslIntegrationTests[]
132
+
133
+
The above code uses the javadoc:org.springframework.boot.testcontainers.service.connection.PemKeyStore[format=annotation] annotation to load the client certificate and key into the keystore and the and javadoc:org.springframework.boot.testcontainers.service.connection.PemTrustStore[format=annotation] annotation to load the CA certificate into the truststore.
134
+
This will authenticate the client against the server, and the CA certificate in the truststore makes sure that the server certificate is valid and trusted.
135
+
136
+
The `SecureRedisContainer` in this example is a custom subclass of `RedisContainer` which copies certificates to the correct places and invokes `redis-server` with commandline parameters enabling SSL.
137
+
138
+
The SSL annotations are supported for the following service connections:
139
+
140
+
* Cassandra
141
+
* Couchbase
142
+
* Elasticsearch
143
+
* Kafka
144
+
* MongoDB
145
+
* RabbitMQ
146
+
* Redis
147
+
148
+
The `ElasticsearchContainer` additionally supports automatic detection of server side SSL.
149
+
To use this feature, annotate the container with javadoc:org.springframework.boot.testcontainers.service.connection.Ssl[format=annotation], as seen in the following example, and Spring Boot takes care of the client side SSL configuration for you:
0 commit comments