文件首頁
MySQL 9.0 參考手冊
相關文件 下載本手冊
PDF (美式信紙尺寸) - 40.0Mb
PDF (A4) - 40.1Mb
Man Pages (TGZ) - 258.2Kb
Man Pages (Zip) - 365.3Kb
Info (Gzip) - 4.0Mb
Info (Zip) - 4.0Mb


25.6.15.3 使用TLS連線

一旦您建立CA和憑證,您可以透過執行ndb_mgm用戶端並帶有--test-tls來測試與管理伺服器的TLS連線可用性,如下所示

$> ndb_mgm --test-tls
No valid certificate.

如果用戶端可以使用TLS連線,則會產生適當的訊息。 您可能需要包含其他ndb_mgm選項,例如--ndb-tls-search-path,以方便TLS連線,如下所示

$> ndb_mgm --test-tls --ndb-tls-search-path="CA:keys"
Connected to management server at localhost port 1186 (using TLS)

如果用戶端在未使用TLS的情況下連線,也會顯示,類似於這裡顯示的內容

$> ndb_mgm
Connected to management server at localhost port 1186 (using cleartext)
$>

您可以讓叢集使用使用ndb_sign_keys建立的CA和憑證,方法是對叢集執行滾動重新啟動,從管理節點開始,應該使用--ndb-tls-search-path選項重新啟動。 完成後,重新啟動資料節點,同樣使用--ndb-tls-search-path--ndb-tls-search-path也支援作為叢集API節點執行的mysqld

為了使TLS運作,連線到叢集的每個節點都必須具有有效的憑證和金鑰。 這包括資料節點、API節點和公用程式。 多個節點可以使用相同的憑證和金鑰檔案。

資料節點記錄TLS連線,並包含所使用的憑證檔案的完整路徑,如下所示

$> ndbmtd -c localhost:1186 --ndb-tls-search-path='CA:keys'
2023-12-19 12:02:15 [ndbd] INFO     -- NDB TLS 1.3 available using certificate file 'keys/ndb-data-node-cert'
2023-12-19 12:02:15 [ndbd] INFO     -- Angel connected to 'localhost:1186'
2023-12-19 12:02:15 [ndbd] INFO     -- Angel allocated nodeid: 5

您可以透過檢查ndb_mgm用戶端中TLS INFO命令的輸出,來驗證叢集節點是否使用TLS連線,如下所示

$> ndb_mgm --ndb-tls-search-path="CA:keys"
-- NDB Cluster -- Management Client --
ndb_mgm> TLS INFO
Connected to management server at localhost port 1186 (using TLS)
 
Main interactive connection is using TLS
Event listener connection is using TLS
 
Server reports 6 TLS connections.

  Session ID:          32
  Peer address:        ::
  Certificate name:    NDB Node Dec 2023
  Certificate serial:  39:1E:4A:78:E5:93:45:09:FC:56
  Certificate expires: 21-Apr-2024
 
  Session ID:          31
  Peer address:        127.0.0.1
  Certificate name:    NDB Node Dec 2023
  Certificate serial:  39:1E:4A:78:E5:93:45:09:FC:56
  Certificate expires: 21-Apr-2024
 
  Session ID:          30
  Peer address:        127.0.0.1
  Certificate name:    NDB Node Dec 2023
  Certificate serial:  39:1E:4A:78:E5:93:45:09:FC:56
  Certificate expires: 21-Apr-2024
 
  Session ID:          18
  Peer address:        127.0.0.1
  Certificate name:    NDB Data Node Dec 2023
  Certificate serial:  57:5E:58:70:7C:49:B3:74:1A:99
  Certificate expires: 07-May-2024
 
  Session ID:          12
  Peer address:        127.0.0.1
  Certificate name:    NDB Data Node Dec 2023
  Certificate serial:  57:5E:58:70:7C:49:B3:74:1A:99
  Certificate expires: 07-May-2024
 
  Session ID:          1
  Peer address:        127.0.0.1
  Certificate name:    NDB Management Node Dec 2023
  Certificate serial:  32:10:44:3C:F4:7D:73:40:97:41
  Certificate expires: 17-May-2024
 
 
    Server statistics since restart
  Total accepted connections:        32
  Total connections upgraded to TLS: 8
  Current connections:               6
  Current connections using TLS:     6
  Authorization failures:            0
ndb_mgm>

如果目前連線使用TLS的目前連線相同,則表示所有叢集連線都正在使用TLS。

一旦為所有節點建立TLS連線,您應該將TLS設為嚴格要求。 對於用戶端,您可以在每個叢集主機的my.cnf檔案中設定ndb-mgm-tls=strict來執行此操作。 透過在叢集config.ini檔案的[mgm default]區段中設定RequireTls=true來在管理伺服器上強制執行TLS要求,然後對叢集執行滾動重新啟動,使此變更生效。 也對資料節點執行此操作,方法是在組態檔案的[ndbd default]區段中設定RequireTls=true;此後,對叢集執行第二次滾動重新啟動,使變更在資料節點上生效。 啟動ndb_mgmd並同時使用--reload--config-file選項,以確保管理伺服器讀取兩個組態檔案變更。

若要取代私密金鑰,請使用ndb_sign_keys --create-key來建立新的金鑰和憑證,並視需要使用--node-id--node-type選項,將取代限制為單一節點ID、節點類型或兩者。 如果此工具找到現有的金鑰和憑證檔案,它會重新命名它們以反映其已退休狀態,並將新建立的金鑰和憑證儲存為活動檔案;下次重新啟動節點時會使用新檔案。

若要在不取代私密金鑰的情況下取代憑證,請使用ndb_sign_keys,但不提供--create-key選項。 這會為現有金鑰建立新的憑證 (而不取代金鑰),並讓舊憑證退休。

ndb_sign_keys也支援遠端金鑰簽署。 使用 SSH,--remote-CA-host選項以user@host格式提供CA主機的SSH位址。 依預設,本機ndb_sign_keys處理程序使用系統ssh公用程式和位址,以在遠端主機上使用正確的選項執行ndb_sign_keys來執行所需的簽署。 或者,如果--remote-openssl=true,則在遠端主機上使用openssl而非ndb_sign_keys

使用遠端簽署時,透過網路傳送的資料是PKCS#10簽署要求,而不是私密金鑰,私密金鑰永遠不會離開本機主機。