UNSOLVED

ragr1

updated

14 years ago

R

ragr1

12 Posts

0

1592

July 28th, 2012 00:00

Using x-emc-date instead of Date for signature calc

For our implementation,  I need to use a "api proxy" between the client and the Atmos server.  The proxy, as Date is an optional header per HTTP spec, is not passing the Date header.

As the Atmos API doc says, instead of the Date field one can use x-emc-date.  I took the Atmos EsuRestAPI java SDK, and modified it to put x-emc-date instead of Date in all occurrences - signature calc, and values in HTTP header.

When I use x-emc-date with or without our proxy, Atmos returns an error. In the same code, if I replace x-emc-date with Date, everything works fine (not through the proxy).

Has anyone tried x-emc-date instead of Date and has been successfully used the Java bindings for REST APIs?

Below is client code log showing headers being sent, and the error message:

EsuRestApi - signRequest(): headers->{content-type=application/octet-stream, x-emc-signature=mT8/pruKhBd33FPYk4Wmg5g70Ag=, x-emc-listable-meta=SampleTag=fooSample, x-emc-date=Sat, 28 Jul 2012 07:28:41 GMT, x-emc-uid=ddb7a344772a49a595270781c9b12156/A79086156178f0235b87}

There was a mismatch between the signature in the request and the signature computed by the server.


  • JasonCwik

    1 Rookie

    •

    281 Posts

    388

    0

    Posted July 30th, 2012 06:00

    When using x-emc-date, you should sign your request with a blank line where the Date value normally goes.  I tested this in the Java API by making the following modification to signRequest:

            // Add the current date and the resource.

            if(headers.containsKey("x-emc-date")) {

                      appendBytes(out, "\n", "UTF-8");

            } else {

                      appendBytes( out, headers.get("Date") + "\n"

                    + path.toLowerCase(), "UTF-8" );

            }

  • ragr1

    12 Posts

    388

    0

    Posted August 6th, 2012 23:00

    On my first try this didn't work.  When adding the "\n" where the Date value should be, why aren't you adding the rest of what goes after the Date value  - "\n" + path.toLowerCase() ?

    Suppose we never use "Date" and its value for the signature and always have "x-emc-date", wouldn't the code simply be change from:

    From:

    appendBytes( out, headers.get("Date") + "\n"
                    + path.toLowerCase(), "UTF-8" );

    To:

    appendBytes( out, "\n" + "\n"

                    + path.toLowerCase(), "UTF-8" );

  • JasonCwik

    1 Rookie

    •

    281 Posts

    388

    0

    Posted August 7th, 2012 06:00

    Sorry, you're correct, I missed the path.  It should be:

            // Add the current date and the resource.

            if(headers.containsKey("x-emc-date")) {

                      appendBytes(out, "\n", "UTF-8");

            } else {

                      appendBytes(out, headers.get("Date") + "\n", "UTF-8");

            }

            appendBytes(out, path.toLowerCase(), "UTF-8");

    If you never use "Date", you could change it to:

           appendBytes(out, "\n", "UTF-8");

           appendBytes(out, path.toLowerCase(), "UTF-8");

    Don't add an extra newline.  It's just an empty string in place of the date.