Skip to content

Commit ff2fc95

Browse files
committed
Document that PKCS8 PEM files should be used whenever possible
Closes gh-37170
1 parent 36629df commit ff2fc95

File tree

1 file changed

+20
-5
lines changed
  • spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto

1 file changed

+20
-5
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/webserver.adoc

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,26 @@ The following example shows setting SSL properties using a Java KeyStore file:
195195
key-password: "another-secret"
196196
----
197197

198+
Using configuration such as the preceding example means the application no longer supports a plain HTTP connector at port 8080.
199+
Spring Boot does not support the configuration of both an HTTP connector and an HTTPS connector through `application.properties`.
200+
If you want to have both, you need to configure one of them programmatically.
201+
We recommend using `application.properties` to configure HTTPS, as the HTTP connector is the easier of the two to configure programmatically.
202+
203+
204+
205+
[[howto.webserver.configure-ssl.pem-files]]
206+
==== Using PEM-encoded files
207+
You can use PEM-encoded files instead of Java KeyStore files.
208+
You should use PKCS#8 key files wherever possible.
209+
PEM-encoded PKCS#8 key files start with a `-----BEGIN PRIVATE KEY-----` or `-----BEGIN ENCRYPTED PRIVATE KEY-----` header.
210+
211+
If you have files in other formats, e.g., PKCS#1 (`-----BEGIN RSA PRIVATE KEY-----`) or SEC 1 (`-----BEGIN EC PRIVATE KEY-----`), you can convert them to PKCS#8 using OpenSSL:
212+
213+
[source,shell,indent=0,subs="verbatim,attributes"]
214+
----
215+
openssl pkcs8 -topk8 -nocrypt -in <input file> -out <output file>
216+
----
217+
198218
The following example shows setting SSL properties using PEM-encoded certificate and private key files:
199219

200220
[source,yaml,indent=0,subs="verbatim",configprops,configblocks]
@@ -209,11 +229,6 @@ The following example shows setting SSL properties using PEM-encoded certificate
209229

210230
See {spring-boot-module-code}/web/server/Ssl.java[`Ssl`] for details of all of the supported properties.
211231

212-
Using configuration such as the preceding example means the application no longer supports a plain HTTP connector at port 8080.
213-
Spring Boot does not support the configuration of both an HTTP connector and an HTTPS connector through `application.properties`.
214-
If you want to have both, you need to configure one of them programmatically.
215-
We recommend using `application.properties` to configure HTTPS, as the HTTP connector is the easier of the two to configure programmatically.
216-
217232

218233

219234
[[howto.webserver.configure-http2]]

0 commit comments

Comments
 (0)