You can configure it in src/main/resources/application.yml
, e.g.
server:
# for testing or development without SSL certs (HTTP) use an "appropriate"
# non-secure port, e.g. 8080
# for HTTPS use an "appropriate" secure port, e.g. 8443
port: 8443
ssl:
# for HTTP set enabled to false, for HTTPS (with required client certs) set to true
enabled: true
# this is the spring cloud gateway _server_ cert
key-store: /etc/pki/tls/private/server.p12
key-store-password: servercertpassword
key-store-type: PKCS12
# this is the "bundle" of CA intermediate/root upon which the client cert has to
# match
trust-store: /etc/pki/ca-trust/extracted/java/cacerts
# this `client-auth` option is where you *require* mutual-TLS, it can alternatively
# be made optional
client-auth: need
trust-store-password: truststorepassword
trust-store-type: JCEKS
management:
# management port without SSL to allow monitoring/etc. without client certs
# e.g. /actuator/health
server:
port: 8080
ssl:
enabled: false
If you have a set of client certs, a server cert, and trust-store / CA bundle, this is an example of how to configure it in Spring Cloud Gateway.
An X509 PreAuthenticatedAuthenticationToken
will be available in your application for successful connections made via mutual TLS, containing the principal/details of the client cert.