azure-ad-b2c / samples

Azure AD B2C custom policy solutions and samples.
846 stars 598 forks source link

Problem with policies/invite code after .net 8 upgrade: GetRSAPublicKey() method comes back null and throws exception "Certificate is not an RSA certificate" #631

Open tomtrost opened 3 months ago

tomtrost commented 3 months ago

Hello. I can't seem to find any documentation or workaround for this issue. I am having an issue wit the .well-known/keys endpoint in the Oidc controller after porting it into my .NET 8 project. I have the policies/invite code running locally and accessing a signed certificate and this endpoint works great, however it doesn't work great when ported into my project. The main difference: my project is .NET 8 whereas the example code is .NET Core 3.1. Consequently, the Microsoft.IdentityModel.Tokens Nuget package (I think that's the culprit) is version 8.0.0 as opposed to 6.6.0 that I have running on the "invite" code.

I noticed that GetRSAPublicKey() method in the jwksModel is returning null, which is throwing that error. I also noticed that this method has quite different approaches after stepping into the different versions. Both projects are processing the exact same signed certificate and seem to be passing similar values into their respective DecodePublicKey methods. I am really at a loss here. I've stepped into the code to try to figure out what's wrong, but end up pretty far "into the weeds" with the cryptographic parsing that goes on. Any advice would be GREATLY appreciated!

tomtrost commented 3 months ago

Solved per vcsjones reply here: https://github.com/dotnet/runtime/issues/86845#issuecomment-1570517304