Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Certificate pinning issue after bunq certificate renewal #115

Closed
1 task
erwindeg opened this issue Apr 19, 2019 · 7 comments · Fixed by #116
Closed
1 task

Certificate pinning issue after bunq certificate renewal #115

erwindeg opened this issue Apr 19, 2019 · 7 comments · Fixed by #116

Comments

@erwindeg
Copy link
Contributor

erwindeg commented Apr 19, 2019

Steps to reproduce:

  1. Create a BunqContext with the Java SDK

What should happen:

  1. Session should be successfully created and payments should succeed

What happens:

  1. Creation fails with com.bunq.sdk.exception.UncaughtExceptionError: Uncaught exception "Certificate pinning failure!"

SDK version and environment

  • Tested on 1.1.0
  • [ X ] Sandbox
  • Production

Extra info:

It looks like your certificate for https://public-api.sandbox.bunq.com/ was renewed last night and now the hardcoded pinned key in the SDK doesn't match the key of the new certificate

@erwindeg erwindeg changed the title Certificate pinning issue after bunt certificate renewal Certificate pinning issue after bunq certificate renewal Apr 19, 2019
@OGKevin
Copy link
Contributor

OGKevin commented Apr 19, 2019

waw 🤦‍♂️ 👏, lets hope that they will be more careful when doing this on prod. This prob means that all SDK's are broken. There is a way you can fix this yourself however, anyone can update the hardcoded cert. I forgot the command however, it was in my notes back in the day. @kojoru If esan is still there, you can ask him if he remembers.

@erwindeg
Copy link
Contributor Author

This should be the new value:
sha256/9Y+oZve6H+r17Kdn+lN5sT0ijgxLyDGIuQtUwLupawA=

@OGKevin
Copy link
Contributor

OGKevin commented Apr 19, 2019

This should be the new value:
sha256/9Y+oZve6H+r17Kdn+lN5sT0ijgxLyDGIuQtUwLupawA=

A nice, create a pull request I would say 😊 Also, it would be a good idea to add a comment in the code in https://github.com/bunq/sdk_java/blob/f3818e3380b472cafd1dbe69bf45a78434f54c84/src/main/java/com/bunq/sdk/context/ApiEnvironmentType.java on the command to run to update it 😊

@erwindeg
Copy link
Contributor Author

Yes, I just did :)

@mwlynch
Copy link

mwlynch commented Apr 19, 2019

FYI: This is how we got the new value.
Run this and grab the new key from the log output.

        String hostname = "public-api.sandbox.bunq.com";

        CertificatePinner certificatePinner = new CertificatePinner.Builder()
                .add(hostname, "sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=")
                .build();

        OkHttpClient client = new OkHttpClient.Builder()
                .certificatePinner(certificatePinner)
                .build();

        Request request = new Request.Builder()
                .url("https://" + hostname)
                .build();
        client.newCall(request).execute();

@OGKevin
Copy link
Contributor

OGKevin commented Apr 19, 2019

hmm, I used to use the openssl command to get this. That was the command I was referring tho. Interesting method however :P

@mwlynch
Copy link

mwlynch commented Apr 19, 2019

There, I figured it out :-P

openssl s_client -connect sandbox.bunq.com:443 -showcerts < /dev/null 2> /dev/null | openssl x509 -pubkey -noout | openssl enc -base64 -d | openssl dgst -sha256 -binary | openssl enc -base64

(and yes, this is considerably more classy than grabbing it from okhttp's error output...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants