Skip to content
New issue

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

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

Already on GitHub? # to your account

OKEX, OKX, getting 50113:Invalid Sign #4946

Open
arass opened this issue Sep 9, 2024 · 5 comments
Open

OKEX, OKX, getting 50113:Invalid Sign #4946

arass opened this issue Sep 9, 2024 · 5 comments

Comments

@arass
Copy link
Contributor

arass commented Sep 9, 2024

Hi.

Getting a lot of

Caused by: 50113:Invalid Sign
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
at com.fasterxml.jackson.databind.introspect.AnnotatedConstructor.call(AnnotatedConstructor.java:128)
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createFromObjectWith(StdValueInstantiator.java:291)

Some stuff goes through. Other stuff dies like that ^^^.

This is how their API signs:
https://github.com/jane-cloud/Open-API-SDK-V5/blob/main/okex-java-sdk-api-v5/src/main/java/com/okex/open/api/client/APIHttpClient.java


   private String sign(final Request request, final String timestamp) {
        final String sign;

        try {
            sign = HmacSHA256Base64Utils.sign(timestamp, this.method(request), this.requestPath(request),
                    this.queryString(request), this.body(request), this.credentials.getSecretKey());
            //System.out.println("签名字符串:"+timestamp+this.method(request)+this.requestPath(request)+this.queryString(request)+this.body(request));
        } catch (final IOException e) {
            throw new APIException("Request get body io exception.", e);
        } catch (final CloneNotSupportedException e) {
            throw new APIException("Hmac SHA256 Base64 Signature clone not supported exception.", e);
        } catch (final InvalidKeyException e) {
            throw new APIException("Hmac SHA256 Base64 Signature invalid key exception.", e);
        }
        return sign;
    }

Yes, I synchronized the server's clock with an atomic clock. Don't know if THEY have though.

@rizer1980
Copy link
Contributor

Hello. @arass

What is the relationship of XChange library to this error?

@arass
Copy link
Contributor Author

arass commented Sep 10, 2024

I am using xchange library to communicate.
And I'm getting the error above.
I simply added THEIR signature code, in case it helps someone analyze any possible differences between the 2 libraries when it comes to signing.

@rizer1980
Copy link
Contributor

ok.
Please post the example(code) to reproduce this error.

@arass
Copy link
Contributor Author

arass commented Sep 10, 2024

Hi.

I don't have the IP to post the code. Just letting you know of this bug.
This is a huge issue and this OKX API is worthless wo a fix for it.
I provided their code for how to calculate the signature. Please compare it.
Their support also suggested to check: to make sure this API doesn't reuse/cache signatures between calls.

Thanks.

@arass
Copy link
Contributor Author

arass commented Oct 15, 2024

Looks like related to #4779

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

No branches or pull requests

2 participants