小编Sha*_*ian的帖子

Error Creating JWT Token using RSA Security Key with key size less than 2048

I'm facing an exception when trying to create a JWT token in C# Web API application.

Test environment

Here is the code responsible for generating RSA keys:

    public SignatureInformation CreateNewSignatureInformation(int length = 0)
    {
        try
        {
            var signatureInformation = new SignatureInformation();

            var rsaProvider = new RSACryptoServiceProvider(length);

            var publicKey = rsaProvider.ToXmlString(false);
            signatureInformation.Public = publicKey;

            var privateKey = rsaProvider.ToXmlString(true);
            signatureInformation.Private = privateKey;

            return signatureInformation;
        }
        catch (Exception)
        { …
Run Code Online (Sandbox Code Playgroud)

c# authentication rsa wif jwt

5
推荐指数
1
解决办法
2821
查看次数

标签 统计

authentication ×1

c# ×1

jwt ×1

rsa ×1

wif ×1