Add Kotlin samples and polish SSL bundle documentation
Closes gh-35105
This commit is contained in:
@@ -84,14 +84,22 @@ See {spring-boot-autoconfigure-module-code}/ssl/PemSslBundleProperties.java[PemS
|
||||
[[features.ssl.applying]]
|
||||
=== Applying SSL Bundles
|
||||
Once configured using properties, SSL bundles can be referred to by name in configuration properties for various types of connections that are auto-configured by Spring Boot.
|
||||
See the sections on <<howto#howto.webserver.configure-ssl,embedded web servers>> and <<data#data,data technologies>> for further information.
|
||||
See the sections on <<howto#howto.webserver.configure-ssl,embedded web servers>>, <<data#data,data technologies>>, and <<io#io.rest-client,REST clients>> for further information.
|
||||
|
||||
|
||||
|
||||
[[features.ssl.bundles]]
|
||||
=== Using SSL Bundles
|
||||
Spring Boot auto-configures a bean of type `SslBundles` that provides access to each of the named bundles configured using the `spring.ssl.bundle` properties.
|
||||
An `SslBundle` can be retrieved from the auto-configured `SslBundles` bean and used to create a `javax.net.ssl.SSLContext` or objects of other types from the `java.net.ssl` package that are typically used to configure SSL connectivity in other APIs.
|
||||
|
||||
An `SslBundle` can be retrieved from the auto-configured `SslBundles` bean and used to create objects that are used to configure SSL connectivity in client libraries.
|
||||
The `SslBundle` provides a layered approach of obtaining these SSL objects:
|
||||
|
||||
- `getStores()` provides access to the key store and trust store `java.security.KeyStore` instances as well as any required key store password.
|
||||
- `getManagers()` provides access to the `java.net.ssl.KeyManagerFactory` and `java.net.ssl.TrustManagerFactory` instances as well as the `java.net.ssl.KeyManager` and `java.net.ssl.TrustManager` arrays that they create.
|
||||
- `createSslContext()` provides a convenient way to obtain a new `java.net.ssl.SSLContext` instance.
|
||||
|
||||
In addition, the `SslBundle` provides details about the key being used, the protocol to use and any option that should be applied to the SSL engine.
|
||||
|
||||
The following example shows retrieving an `SslBundle` and using it to create an `SSLContext`:
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ include::code:MyService[]
|
||||
|
||||
`RestTemplateBuilder` includes a number of useful methods that can be used to quickly configure a `RestTemplate`.
|
||||
For example, to add BASIC authentication support, you can use `builder.basicAuthentication("user", "password").build()`.
|
||||
To add SSL support using an <<features#features.ssl.bundles,SSL bundle>>, you can use `builder.setSslBundle(sslBundle).build()`.
|
||||
|
||||
|
||||
|
||||
@@ -45,6 +44,14 @@ In addition to replacing the auto-configured builder, this also prevents any `Re
|
||||
|
||||
|
||||
|
||||
[[io.rest-client.resttemplate.ssl]]
|
||||
==== RestTemplate SSL Support
|
||||
If you need custom SSL configuration on the `RestTemplate`, you can apply an <<features#features.ssl.bundles,SSL bundle>> to the `RestTemplateBuilder` as shown in this example:
|
||||
|
||||
include::code:MyService[]
|
||||
|
||||
|
||||
|
||||
[[io.rest-client.webclient]]
|
||||
=== WebClient
|
||||
If you have Spring WebFlux on your classpath, you can also choose to use `WebClient` to call remote REST services.
|
||||
|
||||
Reference in New Issue
Block a user