I’m playing around with the next generation .Net SDK and at least half of my calls to upload a file or create a folder are throwing an exception about RSA parameters in a cryptography library.
The full exception is like this:
System.Security.Cryptography.CryptographicException: The specified RSA parameters are not valid. Exponent and Modulus are required. If D is present, it must have the same length as Modulus. If D is present, P, Q, DP, DQ, and InverseQ are required and must have half the length of Modulus, rounded up, otherwise they must be omitted.
at System.Security.Cryptography.CngHelpers.ToBCryptBlob(RSAParameters& parameters)
at System.Security.Cryptography.RSABCrypt.ImportParameters(RSAParameters parameters)
at System.Security.Cryptography.RSA.Create(RSAParameters parameters)
at Microsoft.IdentityModel.Tokens.AsymmetricAdapter.InitializeUsingRsaSecurityKey(RsaSecurityKey rsaSecurityKey, String algorithm)
at Microsoft.IdentityModel.Tokens.AsymmetricAdapter..ctor(SecurityKey key, String algorithm, HashAlgorithm hashAlgorithm, Boolean requirePrivateKey)
at Microsoft.IdentityModel.Tokens.AsymmetricAdapter..ctor(SecurityKey key, String algorithm, HashAlgorithm hashAlgorithm, HashAlgorithmName hashAlgorithmName, Boolean requirePrivateKey)
at Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider.CreateAsymmetricAdapter()
at Microsoft.IdentityModel.Tokens.DisposableObjectPool`1.CreateInstance()
at Microsoft.IdentityModel.Tokens.DisposableObjectPool`1.Allocate()
at Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider.Sign(Byte[] input)
at Microsoft.IdentityModel.JsonWebTokens.JwtTokenUtilities.CreateEncodedSignature(String input, SigningCredentials signingCredentials)
at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.WriteToken(SecurityToken token)
at Box.Sdk.Gen.JwtUtils.CreateJwtAssertion(Dictionary`2 claims, JwtKey key, JwtSignOptions options)
at Box.Sdk.Gen.BoxJwtAuth.RefreshTokenAsync(NetworkSession networkSession)
at Box.Sdk.Gen.BoxJwtAuth.RetrieveTokenAsync(NetworkSession networkSession)
at Box.Sdk.Gen.BoxJwtAuth.RetrieveAuthorizationHeaderAsync(NetworkSession networkSession)
at Fetch.HttpClientAdapter.BuildHttpRequest(String resource, FetchOptions options)
at Fetch.HttpClientAdapter.FetchAsync(String resource, FetchOptions options)
at Box.Sdk.Gen.Managers.FoldersManager.CreateFolderAsync(CreateFolderRequestBody requestBody, CreateFolderQueryParams queryParams, CreateFolderHeaders headers, Nullable`1 cancellationToken)
I’m guessing this is a bug and will be smoothed out as the SDK is further developed. But just in case I’m doing something wrong, I thought I would post here.
Sometimes the code works, sometimes it doesn’t. If I had to guess, I would say that it throws this exception the majority of the time.