Spring Boot 4 HTTPS demo
This demo runs Spring Boot 4.1.0 with embedded Tomcat and Java 25. It serves GET /hello at https://localhost:8443/hello.
The default configuration uses a password-protected PKCS#12 server identity keystore. The project also contains a PEM SSL bundle alternative.
Prerequisites
- A running SSL Teams service with an active Intermediate and leaf issuance permission
- The
sslteamCLI authenticated to that service - Java 25, Maven, OpenSSL, and curl
The demo source is in sslteam-services/demos/spring-boot-4-tomcat-demo.
Generate the certificate artifact
From the demos directory, generate a short-lived certificate with the localhost DNS SAN:
cd sslteam-services/demos
umask 077
mkdir -p private-material/spring-boot
sslteam cert generate \
--name spring-boot-local \
--common-name localhost \
--san "DNS=localhost" \
--output-profile PKCS12_ONLY \
--generate-password \
--out-dir private-material/spring-boot
Set the artifact directory to the directory printed by the CLI:
export DEMO_ARTIFACT_DIR='private-material/spring-boot/leaf-localhost-<issuance-id>'
export DEMO_TLS_KEYSTORE_PASSWORD="$(cat "$DEMO_ARTIFACT_DIR/localhost.p12.password")"
The generated password sidecar is a local handoff file. Protect it and remove it after transferring the password to the approved secret store. Never commit the artifact directory.
Choose the output profile
The profile controls which server identity files are generated:
| Profile | Files | Use here |
|---|---|---|
PKCS12_ONLY |
localhost.p12 and public certificate material |
Recommended for the active Spring configuration |
BOTH |
PKCS#12 plus an unencrypted leaf-key.pem and PEM files |
Use only when the same issuance must serve both PKCS#12 and PEM runtimes |
PEM_ONLY |
PEM certificate and private key, no PKCS#12 file | Use only after switching the demo to the PEM configuration |
BOTH and PEM_ONLY expose an unencrypted PEM private key. Protect leaf-key.pem with filesystem permissions and remove it when it is no longer needed.
Inspect and trust the Root CA
Inspect the public Root certificate and compare its fingerprint with an independently approved value:
openssl x509 \
-in "$DEMO_ARTIFACT_DIR/root-ca.pem" \
-noout -subject -issuer -dates -fingerprint -sha256
On macOS, the default install target is the current user's login Keychain. The CLI uses the native macOS trust store and may ask for Keychain authorization:
export DEMO_ROOT_FINGERPRINT='<approved-sha256-fingerprint>'
sslteam ca trust install \
--certificate "$DEMO_ARTIFACT_DIR/root-ca.pem" \
--confirm-fingerprint "$DEMO_ROOT_FINGERPRINT"
sslteam ca trust verify \
--certificate "$DEMO_ARTIFACT_DIR/root-ca.pem" \
--confirm-fingerprint "$DEMO_ROOT_FINGERPRINT"
The CLI is optional. After independently verifying the fingerprint, you can install the public Root with the normal certificate-store mechanism for the operating system running the client:
macOS Keychain Access
Import root-ca.pem into the current user's login Keychain with Keychain Access
and set Trust > When using this certificate to Always Trust. The command-
line equivalent is:
security add-trusted-cert \
-d \
-r trustRoot \
-k "$HOME/Library/Keychains/login.keychain-db" \
"$DEMO_ARTIFACT_DIR/root-ca.pem"
Linux system CA store
Use the standard location for the distribution, then rebuild its trust bundle:
# Debian or Ubuntu
sudo install -m 0644 "$DEMO_ARTIFACT_DIR/root-ca.pem" \
/usr/local/share/ca-certificates/sslteam-demo-root.crt
sudo update-ca-certificates
# Fedora, RHEL, or compatible distributions
sudo install -m 0644 "$DEMO_ARTIFACT_DIR/root-ca.pem" \
/etc/pki/ca-trust/source/anchors/sslteam-demo-root.crt
sudo update-ca-trust extract
Windows certificate store
Convert the PEM file to DER format, then import it into the current user's Trusted Root Certification Authorities store with PowerShell:
$rootPem = Join-Path $env:DEMO_ARTIFACT_DIR "root-ca.pem"
$rootDer = Join-Path $env:TEMP "sslteam-demo-root.cer"
openssl x509 -in $rootPem -outform DER -out $rootDer
Import-Certificate -FilePath $rootDer -CertStoreLocation Cert:\CurrentUser\Root
The graphical equivalent is to open the certificate, choose Install Certificate, select Current User, and place it in Trusted Root Certification Authorities.
After the Root is installed and verified, macOS clients can use the system trust
store. The request does not need --cacert:
curl https://localhost:8443/hello
If you do not want to change the operating-system trust store, keep trust explicit for one request instead:
curl --cacert "$DEMO_ARTIFACT_DIR/root-ca.pem" \
https://localhost:8443/hello
A Root certificate is a client trust anchor, not the server identity used by
Tomcat. Do not replace either trust-aware request with curl -k.
Run the PKCS#12 configuration
The active application.properties settings are:
server.port=8443
server.ssl.enabled=true
server.ssl.key-store=${DEMO_TLS_KEYSTORE_PATH}
server.ssl.key-store-type=PKCS12
server.ssl.key-store-password=${DEMO_TLS_KEYSTORE_PASSWORD}
server.ssl.key-alias=${DEMO_TLS_KEYSTORE_ALIAS:localhost}
server.ssl.client-auth=none
In the same shell that contains DEMO_ARTIFACT_DIR and DEMO_TLS_KEYSTORE_PASSWORD, run:
cd spring-boot-4-tomcat-demo
export DEMO_TLS_KEYSTORE_PATH="$(cd .. && pwd)/$DEMO_ARTIFACT_DIR/localhost.p12"
export DEMO_TLS_KEYSTORE_ALIAS='localhost'
mvn test
mvn spring-boot:run
In a second terminal, run from sslteam-services/demos/:
curl https://localhost:8443/hello
Expected response:
{"message":"hello over TLS","framework":"spring-boot"}
Do not replace the trust-aware request with curl -k.
Use the PEM alternative
The demo keeps this alternative commented out so PKCS#12 remains the default:
spring.ssl.bundle.pem.server.keystore.certificate=${DEMO_TLS_CERTIFICATE_PATH}
spring.ssl.bundle.pem.server.keystore.private-key=${DEMO_TLS_KEY_PATH}
server.ssl.bundle=server
To use it:
- Generate the artifact with
--output-profile PEM_ONLYorBOTH. - Export the PEM paths:
export DEMO_TLS_CERTIFICATE_PATH="$(pwd)/$DEMO_ARTIFACT_DIR/fullchain.pem"
export DEMO_TLS_KEY_PATH="$(pwd)/$DEMO_ARTIFACT_DIR/leaf-key.pem"
chmod 600 "$DEMO_TLS_KEY_PATH"
- Comment out the active
server.ssl.key-store,server.ssl.key-store-type,server.ssl.key-store-password, andserver.ssl.key-aliassettings. - Uncomment the three PEM settings.
- Run
mvn testandmvn spring-boot:runagain.
The PEM private key is not password-protected, so filesystem and deployment controls are essential.
Verify the chain
openssl verify \
-CAfile "$DEMO_ARTIFACT_DIR/root-ca.pem" \
-untrusted "$DEMO_ARTIFACT_DIR/chain.pem" \
"$DEMO_ARTIFACT_DIR/leaf-cert.pem"
keytool -list -v \
-storetype PKCS12 \
-keystore "$DEMO_TLS_KEYSTORE_PATH"
Confirm the localhost alias, certificate validity, and DNSName: localhost SAN. If the certificate expires or the hostname changes, issue a replacement with every identity clients will use and restart the application.