Я пытаюсь использовать этот пользовательский код политики приглашения для Azure B2C:
https://github.com/azure-ad-b2c/samples/tree/master/policies/invite#signup-with-email-invitation
Я следовал пошаговому руководству и создал сертификат, но когда код достигает метода FromSigningCredentials
, он выдает исключение Certificate is not an RSA certificate.
.
Вот код :
public static JwksKeyModel FromSigningCredentials(X509SigningCredentials signingCredentials)
{
X509Certificate2 certificate = signingCredentials.Certificate;
// JWK cert data must be base64 (not base64url) encoded
string certData = Convert.ToBase64String(certificate.Export(X509ContentType.Cert));
// JWK thumbprints must be base64url encoded (no padding or special chars)
string thumbprint = Base64UrlEncoder.Encode(certificate.GetCertHash());
// JWK must have the modulus and exponent explicitly defined
RSACng rsa = certificate.PublicKey.Key as RSACng;
if (rsa == null)
{
throw new Exception("Certificate is not an RSA certificate.");
}
.
.
.
Сертификат загружен, но после выполнения строки:
RSACng rsa = certificate.PublicKey.Key as RSACng;
rsa
равно нулю.
Это происходит локально и на веб-сайте Azure.
Что мне здесь не хватает?