bunq / sdk_csharp

C# SDK for bunq API
MIT License
35 stars 22 forks source link

Provided client public key has an incorrect modulus length. Modulus length must be "2048", got "1024" #92

Closed M0rph3v5 closed 6 years ago

M0rph3v5 commented 6 years ago

Steps to reproduce:

  1. Create an Azure Function which runs the following code:

BunqContext.LoadApiContext(ApiContext.Create(ApiEnvironmentType.SANDBOX, "key", "description"));

What should happen:

  1. Assume no error and a succesfull session start

What happens:

  1. Errors! -> Provided client public key has an incorrect modulus length. Modulus length must be "2048", got "1024"

Traceback

SDK version and environment

Response id

Extra info:

runs on netstandard,

OGKevin commented 6 years ago

Thanks for reporting @M0rph3v5

As you've provided a response id I take it that this error came in back from the API and that no exception was thrown in the SDK itself as an actually SDK error ?

@michielpost do you mind looking into this one ?

M0rph3v5 commented 6 years ago

@OGKevin that's correct, searching provides me with: https://github.com/bunq/sdk_csharp/issues/26#issuecomment-361884281

Having that same issue, but on .net 4.6 referring to https://github.com/dotnet/corefx/issues/12388

Not sure if that's related at all though, the SecurityUtils seems to handle the RSA key size the correct way.

M0rph3v5 commented 6 years ago

I can post the full response if that's useful when I get home.

OGKevin commented 6 years ago

@M0rph3v5 no need for full response, thats what the response id is for :P.

Ill take a look at this and see whats up. C# is not one of my strongest skills however so any help is appreciated.

M0rph3v5 commented 6 years ago

@OGKevin hah makes sense :P, it isn't my strong suit either. I just want to build stuff with it, not run in these vague problems 😅

any luck yet?

BasvdM commented 6 years ago

If you change the method

public static RSA GenerateKeyPair() {
    var rsa = RSA.Create();
    rsa.KeySize = RSA_KEY_SIZE;
    return rsa;
}

to

public static RSA GenerateKeyPair() {
    var csp = new RSACryptoServiceProvider(RSA_KEY_SIZE);
    var rsa = (RSA)csp;
    return rsa;
}

i think it will work.

Maybe this will help to update the SDK.

OGKevin commented 6 years ago

@BasvdM thanks for this!

Do you mind creating a pull request ?

BasvdM commented 6 years ago

@OGKevin I won't mind at all, but I'm all new to Github. What do you mean with pull request and what do I have to do exactly?

Sorry for my ignorance...

OGKevin commented 6 years ago

@BasvdM i think this explains it well enough: https://akrabat.com/the-beginners-guide-to-contributing-to-a-github-project/

Also make sure when you make a commit the following is in the commit msg: bunq/sdk_csharp#92.

Let me know if you manage if not ill do it my self 😉

sanderlanghorstredhotminute commented 6 years ago

Running sdk_csharp 1.0.0 with a .net 4.7 application generates the same errors, still. When is this being fixed?