Fortanix SDKMS

本教學將說明如何設定 KES 伺服器,以 Fortanix SDKMS 作為持久且安全的金鑰儲存庫。

K E S C l i e n t K E S S e r v e r F o r t a n i x S D K M S

Fortanix SDKMS

  1. 建立應用程式

    註冊新的應用程式,該應用程式可以驗證並與 Fortanix SDKMS 執行個體通訊。

    • 前往 Fortanix SDKMS UI 中的 Apps 區段。

      Step 1

    • 為應用程式指定描述性名稱,例如 KES

    • 選取 REST API 作為整合

    • 選擇 API 金鑰 作為驗證方法

      Step 2

  2. 指派群組

    指派的群組會作為應用程式的預設群組。新建立的金鑰會屬於此群組,除非您在 KES 組態檔中指定明確的群組 ID。

    Step 3

  3. 建立應用程式,並複製應用程式的 API 金鑰。

    此金鑰是 KES 用於與 Fortanix SDKMS 通訊的存取憑證。

    Step 4

KES 伺服器設定

KES 伺服器需要 TLS 私密金鑰和憑證。

KES 伺服器是預設安全,且只能使用 TLS 執行。為了簡化,本教學使用自我簽署憑證。

對於生產環境的設定,我們強烈建議使用由可信任憑證授權單位簽署的憑證。這可以是您內部的 CA,或是像是 Let’s Encrypt 這類的公開 CA。
  1. 為 KES 伺服器產生 TLS 私鑰和憑證

    以下指令會產生新的 TLS 私鑰 server.key 和一個自簽署的 X.509 憑證 server.cert,該憑證是發給 IP 位址 127.0.0.1 和 DNS 名稱 localhost(作為 SAN)。請自訂指令以符合您的設定。

    kes tool identity new --server --key server.key --cert server.cert --ip "127.0.0.1" --dns localhost
    

    任何其他用於產生 X.509 憑證的工具也都可以使用。例如,您可以使用 openssl

    openssl ecparam -genkey -name prime256v1 | openssl ec -out server.key
    
    openssl req -new -x509 -days 30 -key server.key -out server.cert \
        -subj "/C=/ST=/L=/O=/CN=localhost" -addext "subjectAltName = IP:127.0.0.1"
    
  2. 建立私鑰和憑證

    kes tool identity new --key=app.key --cert=app.cert app
    

    您可以隨時計算 app 身分。

    kes tool identity of app.cert
    
  3. 建立設定檔

    建立名為 server-config.yml設定檔

    address: 0.0.0.0:7373
    
    admin:
      identity: disabled  # We disable the admin identity since we don't need it in this guide 
    
    tls:
      key : server.key
      cert: server.cert
    
    policy:
      my-app:
         allow:
         - /v1/key/create/my-app*
         - /v1/key/generate/my-app*
         - /v1/key/decrypt/my-app*    
        identities:
        - ${APP_IDENTITY}
    
     keystore:
       fortanix:
         sdkms:
           endpoint: "<your-fortanix-sdkms-endpoint>"    # Use your Fortanix instance endpoint.
           credentials:
             key: "<your-api-key>" # Insert the application's API key      
    
  4. 在新視窗/分頁中啟動 KES 伺服器

    export APP_IDENTITY=$(kes tool identity of app.cert)
    
    kes server --config=server-config.yml --auth=off
    
    此指令使用 --auth=off,因為我們的 root.certapp.cert 憑證是自簽署的。
  5. 在另一個分頁中,連線至伺服器

    export KES_CLIENT_CERT=app.cert
    export KES_CLIENT_KEY=app.key
    kes key create -k my-app-key
    
    因為我們使用自簽署憑證,所以需要 -k
  6. 從先前建立的 my-app-key 衍生和解密資料金鑰

    kes key derive -k my-app-key
    {
       plaintext : ...
       ciphertext: ...
    }
    
    kes key decrypt -k my-app-key <base64-ciphertext>
    

搭配 MinIO 伺服器使用 KES

MinIO 伺服器需要 KES 才能啟用伺服器端資料加密。

請參閱KES for MinIO 指導說明,以取得搭配 MinIO 伺服器使用您新 KES 伺服器所需的其他步驟。

組態參考

以下章節說明金鑰加密服務 (KES) 組態設定,以使用 Fortanix SDKMS 作為根 KMS 來儲存外部金鑰,例如用於 MinIO 伺服器上伺服器端加密的金鑰。

MinIO 伺服器需要擴充權限
MinIO 伺服器 RELEASE.2023-02-17T17-52-43Z 開始,MinIO 需要擴充的 KES 權限才能運作。本節中的範例組態包含所有必要的權限。