XChange icon indicating copy to clipboard operation
XChange copied to clipboard

OKEX, OKX, getting 50113:Invalid Sign

Open arass opened this issue 1 year ago • 5 comments

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.

arass avatar Sep 09 '24 20:09 arass

Hello. @arass

What is the relationship of XChange library to this error?

rizer1980 avatar Sep 09 '24 21:09 rizer1980

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.

arass avatar Sep 10 '24 00:09 arass

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

rizer1980 avatar Sep 10 '24 10:09 rizer1980

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 avatar Sep 10 '24 15:09 arass

Looks like related to https://github.com/knowm/XChange/issues/4779

arass avatar Oct 15 '24 03:10 arass