nativescript-community/https

[IOS] Object key sorting by NSMutableDictionary and NSMutableArray

kefahB opened this issue · 3 comments

Hi @EddyVerbruggen

sorry, I've been asking you a lot lately ..

I have a question about using NSMutableDictionary and NSMutableArray on IOS before sending the body; for security reasons I sign all data & params into header and I do compare on server side if the data was changed.... the problem is I have a differences between the body signed before sending the data and the body send by the plugin !

I have done some debugging :

  • I tried to sorting the Object key before signing to matching with NSMutableDictionary but on server side the signed header was correct, but the body it dose not match neither to the order in the request nor as I ordered it before sending ^^

I don't know if you have specific reason for using NSMutableDictionary and NSMutableArray .. if not sending the opts.body directly resolve conflict

Hi @farfromrefug,

What do you think about that ? NSMutableDictionary and NSMutableArray do ordering data and also remove the key:value if the value it is NULL what i understand but the real problem that on server side with the ordering of data, ex: will proceed to ordering data by alphabetical first then the numeric...

Do you think there is a way to do some think with ?

@kefahB funny you said that we implemented that very recently :D
And there is no way to force the order. You will never be sure to have the same order between js and php for example.
What we did is write a simple little function to generate a "string" signature:
The JS one
The PHP one

Hi,

I've found the way to mange this on php side that is not a problem, it was just a question if there is a way to prevent this ;)

I will close this