TLS 和 SSL
閘道器可以透過遵循常規的 Spring 伺服器配置來監聽 HTTPS 請求。以下示例展示瞭如何實現
application.yml
server:
ssl:
enabled: true
key-alias: scg
key-store-password: scg1234
key-store: classpath:scg-keystore.p12
key-store-type: PKCS12
您可以將閘道器路由到 HTTP 和 HTTPS 後端。如果要路由到 HTTPS 後端,您可以使用以下配置將閘道器配置為信任所有下游證書
application.yml
spring:
cloud:
gateway:
httpclient:
ssl:
useInsecureTrustManager: true
使用不安全的信任管理器不適用於生產環境。對於生產部署,您可以使用以下配置為閘道器配置一組它可信任的已知證書
application.yml
spring:
cloud:
gateway:
httpclient:
ssl:
trustedX509Certificates:
- cert1.pem
- cert2.pem
如果 Spring Cloud Gateway 沒有配置受信任的證書,則會使用預設的信任庫(您可以透過設定 `javax.net.ssl.trustStore` 系統屬性來覆蓋)。