Skip to content

Add ability to set cert thumbprint in JwsBuilder - #41

Merged
Firstyear merged 1 commit into
kanidm:mainfrom
dmulder:dmulder/set_x5t
Jul 8, 2025
Merged

Add ability to set cert thumbprint in JwsBuilder#41
Firstyear merged 1 commit into
kanidm:mainfrom
dmulder:dmulder/set_x5t

Conversation

@dmulder

@dmulder dmulder commented Jul 2, 2025

Copy link
Copy Markdown
Collaborator

Implements # .

  • cargo fmt has been run
  • cargo test has been run and passes
  • documentation has been updated with relevant examples (if relevant)

Signed-off-by: David Mulder <dmulder@samba.org>
@dmulder
dmulder requested a review from Firstyear July 2, 2025 21:40
@dmulder

dmulder commented Jul 2, 2025

Copy link
Copy Markdown
Collaborator Author

This is required for a MS ConfidentialClientApplication.
To authenticate as a "confidential" client in Entra Id:

  1. Create an rsa256 key pair (I'm using LoadableRS256Key/RS256Key from hsm-crypto).
  2. Self sign a certificate using the rsa256 private key.
  3. Upload the self signed certificate to Entra Id for Application certificate authentication.
  4. Sign a JWT via the rsa256 private key, formatted as follows:
    {
      "alg": "RS256",
      "kid": "3ee6dfce3de665244ba03b59ecc7d50360fc1655e3d361e0304daca8ed57c700",
      "x5t": "FHBvbp5DupufYzW5TL/qetRR8dg="
    }.{
      "aud": "https://login.microsoftonline.com/6973bb37-65f8-440e-b39e-dd57da64f6cf/oAuth2/v2.0/token",
      "sub": "30adc3ea-f3f4-4c31-942a-8c6a44f46a00",
      "iss": "30adc3ea-f3f4-4c31-942a-8c6a44f46a00",
      "jti": "7519ddb3-c0c8-4de2-9854-27acf6f5ce31",
      "iat": 1751492211,
      "exp": 1751492811
    }.[Signature]
    
    Where the x5t is a base64 encoded sha1 digest of the certificate der (I attempted without this, and it is actually mandatory).
  5. Send this JWT in a token request (client_assertion parameter), and MS responds with an access token.

@dmulder
dmulder requested a review from yaleman July 2, 2025 21:48
@Firstyear
Firstyear merged commit 64bbf41 into kanidm:main Jul 8, 2025
1 check passed
@dmulder
dmulder deleted the dmulder/set_x5t branch July 8, 2025 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants