Quick revision
The short answer
With SSL bundles, we define a PEM bundle with spring.ssl.bundle.pem.server.keystore.certificate and spring.ssl.bundle.pem.server.keystore.private-key pointing to the certificate and key files, and then set server.ssl.bundle=server so the embedded server uses it. Java keystores in JKS or PKCS12 format use spring.ssl.bundle.jks.<name> instead. SSL bundles were added in Spring Boot 3.1.
What to remember
In this answer, we configured HTTPS with SSL bundles. We defined a PEM bundle with spring.ssl.bundle.pem.server.keystore.certificate and private-key, pointed the server at it with server.ssl.bundle=server, verified the handshake with curl and openssl, saw that JKS and PKCS12 stores use spring.ssl.bundle.jks.<name>, and added a trust store for mutual TLS. SSL bundles have been available since Spring Boot 3.1.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
With SSL bundles, we define a PEM bundle with spring.ssl.bundle.pem.server.keystore.certificate and spring.ssl.bundle.pem.server.keystore.private-key pointing to the certificate and key files, and then set server.ssl.bundle=server so the embedded server uses it. Java keystores in JKS or PKCS12 format use spring.ssl.bundle.jks.<name> instead. SSL bundles were added in Spring Boot 3.1.
Why this question is asked
Before Spring Boot 3.1, every place that needed TLS had its own way of configuring it: server.ssl properties for the web server, custom SSLContext code for each HTTP client, and separate settings for Kafka, Redis or MongoDB. Converting certificates into Java keystores was a common chore. SSL bundles bring all of this into one named definition that any component can use. Interviewers ask this coding question to see whether we know the current way to set up HTTPS. In this answer, we will recap the files involved, configure a PEM bundle for the server, verify it, look at the keystore variant, and add a trust store for client certificates.
1A Quick Recap of Certificates, Keys and Bundles
To serve HTTPS, the server needs two things. The certificate is the public part: it contains the server's public key and the names it is valid for, signed by a certificate authority. The private key is the secret that proves the server owns that certificate. PEM is the common text format for both, the files that begin with BEGIN CERTIFICATE or BEGIN PRIVATE KEY, and it is what tools such as cert-manager and Let's Encrypt produce.
An SSL bundle is Spring Boot's name for a group of trust material: a key store, which holds our own certificate and key, and optionally a trust store, which holds the certificates of authorities we trust. We give the bundle a name, here server, and then refer to it by name wherever TLS is needed.
2Defining a PEM Bundle and Using It on the Server
The configuration has two halves: define the bundle, then point the server at it.
- PEM files on disk
tls.crtandtls.keyfrom cert-manager or a CA - SSL bundle 'server'
spring.ssl.bundle.pem.server.keystore.* - SslBundles registryevery bundle available by name
- Embedded server
server.ssl.bundle=server - HTTPS on port 8443TLS handshake uses the bundle's key
5 layers, from the top down. Step through them one at a time.
The locations accept classpath: or file: prefixes, so for local development we can keep a test certificate in src/main/resources and use classpath:certs/dev.crt. In production the files usually come from a mounted secret, which is why the example uses file: paths. The certificate file should contain the full chain, our certificate followed by any intermediate certificates, otherwise some clients cannot build a path to a trusted root.
Notice that server.ssl.bundle replaces the older properties such as server.ssl.key-store and server.ssl.key-store-password. We do not need to convert the PEM files into a keystore, because Boot reads them directly.
3Checking That It Works
Once the application starts, we can confirm which certificate the server presents and that HTTPS answers.
If the application fails to start instead, the error usually names the bundle and the file, for example a missing file or a key that does not match the certificate. A key in an unexpected format, such as an encrypted key without a password, also fails at startup, which is better than failing on the first handshake.
4Using a JKS or PKCS12 Keystore Instead
Some organisations still distribute certificates as Java keystores. For those, the bundle type is jks, which covers both the old JKS format and the standard PKCS12 format.
Notice that the password comes from an environment variable rather than being written in the file. The server configuration, server.ssl.bundle=server, is the same for both types, which is the point of bundles: the consumer does not care how the material is stored.
5Adding a Trust Store for Client Certificates
If we want mutual TLS, where clients must present their own certificate, the bundle also needs a trust store with the authority that signed the client certificates, and the server must be told to require them.
The same bundle name can then be reused by outgoing clients, for example a RestClient that must present a certificate to another service. That reuse is the main reason SSL bundles exist.
6Follow-up questions
Which Spring Boot version do we need?
SSL bundles were added in Spring Boot 3.1, and reloading a bundle when its files change came in 3.2. On Boot 2.x or 3.0, we use the older server.ssl.key-store properties, and for PEM files we would usually convert them into a PKCS12 keystore first.
Can we put the PEM content directly into the property instead of a file?
Yes, the certificate and private-key properties also accept the PEM text itself, which is sometimes used with environment variables. Files are usually easier to rotate and keep secrets out of configuration dumps, so I prefer mounted files.
What else can use the same bundle?
Besides the web server, Boot lets several clients use a bundle by name, for example RestClient and WebClient through RestClientSsl and WebClientSsl, and connections to data stores such as Redis, MongoDB, Kafka and others through their own ssl.bundle properties. Check your version for the exact list.
7Conclusion
In this answer, we configured HTTPS with SSL bundles. We defined a PEM bundle with spring.ssl.bundle.pem.server.keystore.certificate and private-key, pointed the server at it with server.ssl.bundle=server, verified the handshake with curl and openssl, saw that JKS and PKCS12 stores use spring.ssl.bundle.jks.<name>, and added a trust store for mutual TLS. SSL bundles have been available since Spring Boot 3.1.
Open with
Since Spring Boot 3.1 I would use an SSL bundle, which is a named group of TLS material that any component can use. For PEM files, I define the bundle first: spring.ssl.bundle.pem.server.keystore.certificate points to the certificate file, which should include the intermediate certificates, and spring.ssl.bundle.pem.server.keystore.private-key points to the key file.
Then, if they want more
Both accept file: or classpath: locations, and there is a private-key-password property if the key is encrypted. Then I tell the embedded server to use it with server.ssl.bundle=server and set the port, for example 8443. Boot reads PEM directly, so there is no need to convert anything into a keystore.
If the certificates come as a Java keystore instead, I use spring.ssl.bundle.jks.server with keystore.location, password and type, JKS or PKCS12, and the server setting stays the same. I check it with curl -v or openssl s_client to see the certificate subject, expiry and that the chain verifies.
If I need mutual TLS, I add a truststore certificate to the bundle and set server.ssl.client-auth to need. The nice part is that the same bundle name can then be reused by outgoing clients such as RestClient, so TLS is configured in one place.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Spring Boot 3.1
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Boot reference
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Configure HTTPS for a Spring Boot server using a PEM certificate and key with SSL bundles.": https://scrivio-interview-library.netlify.app/spring-boot/embedded-servers/0daeb8271b/