X5T ヘッダーの特定

X5T ヘッダーは、プライベート キー JWT 認証の Microsoft Entra ID 構成に必要です。

次のいずれかの方法で、X5T ヘッダー値を使用してサーバーの証明書のフィンガープリントを見つけます。

xxd および openssl コマンドの使用

xxd および openssl コマンドを使用すると、サムプリント (ハッシュ) の 16 進表現が Base64 エンコード形式に変換されます。

echo <thumbprint> | xxd -r -p | openssl enc -a

以下のコマンドを使用します。

  • echo <thumbprint>: このコマンドはサムプリントを出力します。<thumbprint> を実際のサムプリント文字列に置き換えてください。
  • xxd -r -p: xxd コマンドに -r -p オプションを指定すると、サムプリントの 16 進ダンプが 16 進数から 2 進数に逆変換されます。
  • openssl enc -a: openssl enc -a コマンドは、2 進数のデータを Base64 にエンコードします。

上記のコマンドのサンプル出力:

$ echo "09B3D84C6B5684B8A33599C88C5AAA411F5969C6" | xxd -r -p | openssl enc -a
CbPYTGtWhLijNZnIjFqqQR9ZacY=

Windows で Certutil と PowerShell を使用する

このコマンドは certutil を使用しますが、 -encode オプションを指定すると、thumbprintbinary の 2 進数のデータが Base64 形式にエンコードされます。

echo <thumbprint> > thumbprinthex;
certutil -f -decodehex thumbprinthex thumbprintbinary;      
certutil -f -encode thumbprintbinary base64.txt;
get-content base64.txt | Where-Object { -not $_.Contains('-----') } | Out-File x5t.txt

上記のコマンドのサンプル出力:

PS C:\x5ttest> echo 09B3D84C6B5684B8A33599C88C5AAA411F5969C6 > thumbprinthex;
PS C:\x5ttest> certutil -f -decodehex thumbprinthex thumbprintbinary;
Input Length = 86
Output Length = 20
CertUtil: -decodehex command completed successfully.
PS C:\x5ttest> certutil -f -encode thumbprintbinary base64.txt;
Input Length = 20
Output Length = 86
CertUtil: -encode command completed successfully.
PS C:\x5ttest> get-content base64.txt | Where-Object { -not $_.Contains('-----') } | Out-File x5t.txt
PS C:\x5ttest> cat .\x5t.txt
CbPYTGtWhLijNZnIjFqqQR9ZacY=