RSAキーが2048ビット未満の場合、Identity Serverにエラーがスローされる


解説

2021年9月以降に更新されたWindows Serverコンテナを含むSitecore製品のイメージを使用すると、Sitecore Identity Serverの認証に問題が発生し(例:Docker Composeのセットアップのログインに成功せず、https://xp1id.localhost/connect/authorizeページにリダイレクトされる)、Sitecore Identity Serverのログに以下のようなエラーが表示される可能性があります。

[15:58:47] IdentityServer4.Hosting.IdentityServerMiddleware [Fatal] Unhandled exception: "IDX10630: The '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]' for signing cannot be smaller than '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]' bits. KeySize: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'. (Parameter 'key.KeySize')"
System.ArgumentOutOfRangeException: IDX10630: The '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]' for signing cannot be smaller than '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]' bits. KeySize: '[PII is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'. (Parameter 'key.KeySize')
   at Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider.ValidateAsymmetricSecurityKeySize(SecurityKey key, String algorithm, Boolean willCreateSignatures)
   at Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider..ctor(SecurityKey key, String algorithm, Boolean willCreateSignatures) ...

本事象は、RSAキーのサイズが2048ビット未満のIdentity Server証明書(k8sでは「sitecore-identitycertificate.txt」、「compose.env」のファイルでは「SITECORE_ID_CERTIFICATE」)を生成するときに発生します。 

解決策

本事象を解決するには、次のいずれかの方法をご検討ください。

  1. デプロイメント(IdentityおよびSSL )に使用される証明書のRSAキーのサイズが、少なくとも2048ビット(ほとんどのツールはこれをデフォルトで使用するようになっています)であることを確認します。
  2. 旧バージョンのSitecore Docker Toolsを使用している場合、「Get-SitecoreCertificateAsBase64String」関数に「Keylength」パラメーターを指定します:
    • Sitecore Identity Server用の、鍵長2048ビットのRSAキーを持つ新しいクライアント証明書を作成します。
    • .envファイルをアップデートします。
    • コンテナを再コンポーズします。