Spring Cloud TLS / SSL

2024-01-05 16:23 更新

網(wǎng)關(guān)可以通過遵循常規(guī)的Spring服務(wù)器配置來偵聽https上的請求。例:

application.yml。 

server:
  ssl:
    enabled: true
    key-alias: scg
    key-store-password: scg1234
    key-store: classpath:scg-keystore.p12
    key-store-type: PKCS12

網(wǎng)關(guān)路由可以同時路由到http和https后端。如果路由到https后端,則可以使用以下配置將網(wǎng)關(guān)配置為信任所有下游證書:

application.yml。 

spring:
  cloud:
    gateway:
      httpclient:
        ssl:
          useInsecureTrustManager: true

使用不安全的信任管理器不適用于生產(chǎn)。對于生產(chǎn)部署,可以為網(wǎng)關(guān)配置一組可以通過以下配置信任的已知證書:

application.yml。 

spring:
  cloud:
    gateway:
      httpclient:
        ssl:
          trustedX509Certificates:
          - cert1.pem
          - cert2.pem

如果Spring Cloud網(wǎng)關(guān)未配置受信任的證書,則使用默認的信任存儲(可以使用系統(tǒng)屬性javax.net.ssl.trustStore覆蓋)。

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號