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
It is now possible to make your web server TLS enabled using properties such as server.ssl.key-store.
However, it only supports Keystore and does not support the widely used PEM format.
In Kubernetes, it is common to store TLS certs as PEM files in Secret. cert-manager, which is popular for issuing certificates, also creates a Secret in PEM format.
If my understanding is correct, in order to enable TLS using this PEM file in a Spring Boot application, you need to convert it to a jks file using keytool. In Kubernetes initContainer to mount the TLS PEM file from Secret and perform this conversion process is required, which is very painful.
As far as I can simply find out, Tomcat and Netty (maybe others) can pass PEM files directly in addition to the KeyStore to enable TLS as follows.
// Netty@BeanpublicNettyServerCustomizercustomizer() {
returnhttpServer -> httpServer.secure(sslContextSpec -> {
Http11SslContextSpecspec = Http11SslContextSpec.forServer(newFile("<path to server.crt>"), newFile("<path to server.key>"));
sslContextSpec.sslContext(spec);
});
}
// Tomcat@BeanpublicTomcatConnectorCustomizercustomizer() {
returnconnector -> {
AbstractHttp11JsseProtocol<?> protocol = (AbstractHttp11JsseProtocol) connector.getProtocolHandler();
protocol.setSSLEnabled(true);
protocol.setSSLCertificateFile("<path to server.crt>");
protocol.setSSLCertificateKeyFile("<path to server.key>");
};
}
It tested above code with self-signed certificates generated as follows
It is now possible to make your web server TLS enabled using properties such as
server.ssl.key-store
.However, it only supports Keystore and does not support the widely used PEM format.
In Kubernetes, it is common to store TLS certs as PEM files in Secret. cert-manager, which is popular for issuing certificates, also creates a Secret in PEM format.
If my understanding is correct, in order to enable TLS using this PEM file in a Spring Boot application, you need to convert it to a jks file using keytool. In Kubernetes initContainer to mount the TLS PEM file from Secret and perform this conversion process is required, which is very painful.
As far as I can simply find out, Tomcat and Netty (maybe others) can pass PEM files directly in addition to the KeyStore to enable TLS as follows.
It tested above code with self-signed certificates generated as follows
It would be very convenient if this was provided in the auto configuration.
(Tip: cert-manager uses
PKCS#1
format by default. It won't work unless you setPKCS#8
incertificate.spec.privateKey.encoding
)related issue #24940
The text was updated successfully, but these errors were encountered: