Skip to content

Fallback to RS256 when certificate PSS signing is unsupported #6125

Description

Problem

MSAL prefers PS256/PSS for certificate client assertions against Microsoft Entra authorities. Some certificate private-key providers reject RSASignaturePadding.Pss and throw CryptographicException, even though the same key can sign successfully with PKCS#1 v1.5.

Certificate metadata and legacy APIs are not reliable capability signals. A certificate may expose RSACryptoServiceProvider through one API while the RSA instance MSAL uses can sign PSS successfully.

Expected behavior

MSAL should handle this internally without caller configuration:

  • Attempt the preferred PS256/PSS assertion first.
  • If PSS signing throws CryptographicException, rebuild the JWT header as RS256 with x5t and retry using PKCS#1 padding.
  • Reuse the same encoded payload so claims and jti remain stable.
  • Preserve PS256/PSS for providers that support it.
  • Continue including x5c when requested.

Test coverage

Add an HTTP-pipeline test that performs normal AcquireTokenForClient, forces the cryptography provider to reject PSS, inspects the posted client_assertion, and verifies its RS256 header and PKCS#1 SHA-256 signature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions