private void RunTest(string testFlavor) { using (StartLog(out var loggerFactory, testFlavor)) { var logger = loggerFactory.CreateLogger(testFlavor); for (var i = 0; i < 100; i++) { var key = CryptoUtilities.CreateTestKey(); try { CryptographyHelpers.GetRSAParameters(new SigningCredentials(key, "RS256")); } catch (CryptographicException e) { LogKeyData(logger, i, key, e); throw; } } } }
private SigningCredentialsDescriptor CreateDescriptor(X509Certificate2 certificate) { CryptographyHelpers.ValidateRsaKeyLength(certificate); var credentials = new SigningCredentials(new X509SecurityKey(certificate), CryptographyHelpers.FindAlgorithm(certificate)); return(new SigningCredentialsDescriptor( credentials, CryptographyHelpers.GetAlgorithm(credentials), certificate.NotBefore, certificate.NotAfter, GetMetadata())); IDictionary <string, string> GetMetadata() { var rsaParameters = CryptographyHelpers.GetRSAParameters(credentials); return(new Dictionary <string, string> { [JsonWebKeyParameterNames.E] = Base64UrlEncoder.Encode(rsaParameters.Exponent), [JsonWebKeyParameterNames.N] = Base64UrlEncoder.Encode(rsaParameters.Modulus), }); } }