免責事項:これは英文の記事「kubectl vsphere login fails with "tls: failed to verify certificate: x509: certificate specifies an incompatible key usage Cause Identification"」の日本語訳です。記事はベストエフォートで翻訳を進めているため、ローカライズ化コンテンツは最新情報ではない可能性があります。最新情報は英語版の記事で参照してください。
vCenter → Workload Management → Supervisor → Configure → Certificate から Workload Platform Management(または Supervisor)の証明書を置き換えた後、以下のエラーが発生し、「kubectl vsphere login」が失敗します:
$ kubectl vsphere login --server=https://aa.bb.cc.dd
Error occurred during HTTP request: Get "https://aa.bb.cc.dd/wcp/loginbanner" : tls: failed to verify certificate: x509: certificate specifies an incompatible key usage
There was an error when trying to connect to the server.
Please check the server URL and try again.
vSphere with Tanzu 8.0.x
このエラーメッセージは、新しく署名されたサーバー証明書に「キー使用目的(key usage)」の互換性の問題があることを示しています。
新しい証明書を確認したところ、正しい使用目的である「TLS Web Server Authentication」ではなく、「TLS Web Client Authentication」として署名されていることが分かりました。
X509v3 extensions:
X509v3 Subject Alternative Name:
DNS:supervisor.mylab.local, IP Address:aa.bb.cc.dd
X509v3 Key Usage: critical
Digital Signature, Key Encipherment
X509v3 Extended Key Usage:
TLS Web Client Authentication <<<===!!! This is wrong, it should be TLS Web Server Authentication
本ケースでは、サーバー証明書は不明な署名ツールを使用して、カスタムの認証局(Certificate Authority)によって署名されていました。お客様の証明書署名組織において、サーバー認証用として必要な「TLS Web Server Authentication」ではなく、誤って「TLS Web Client Authentication」という不適切なキー使用目的が割り当てられていました。
本問題を解決するため、正しいキー使用目的である 「TLS Web Server Authentication」 を指定して、新しいサーバー証明書を生成および署名してください。