Page 1 of 1

Interacting with https

Posted: Mon Jul 08, 2013 3:35 pm
by viro
Hey Guys, I'm trying to let my app login over https and save the cookie for further requests.

It's kind of weird because sometimes it just works and sometimes it does not! On windows it just works fine when setting this:

Code: Select all

libUrlSetSSLVerification false
I use this to login:

Code: Select all

local vName,vPass,vBody
global vUrl,vHeader
on changeLogin
   ask question "Wie lautet ihr Benutzername?"
   put it into vName
   ask password "Wie lautet ihr Passwort?"
   put it into vPass 
   put the text of fld "Json" into vBody
   replace "xx" with vName in vBody
   replace "yy" with vPass in vBody
   globaleUrl #sets the variable to default url eg "https://myurl,com"
   put "/api/login"after vUrl
   post vBody to url vUrl
   answer the result && it
   go to next
end changeLogin
My Json string to login looks like:

Code: Select all

{
"username":"xx","password":"yy"
}
The header looks like this:

Code: Select all

User-Agent: Appname
Content-Type: application/json; charset=utf-8
And to get the cookie into the header i use this:

Code: Select all

put char 5 to -1 of line lineoffset("Set-Cookie: PLAY_SESSION=",libURLLastRHHeaders()) of libURLLastRHHeaders() after vHeader
Every line in the header is followed by return eg "appname&&return utf-8&&return".
I tried it on two servers; 1 server with selfsigned ssl and 1 server with verified digi cert...

Hope somebody can help me out with this...

Re: Interacting with https

Posted: Thu Aug 08, 2013 7:46 am
by viro
So it turned out it was a server problem where theserver has installed siogned certificates but it was not chained properly.
Actually livecode is able to login to webservices (if the webservice sends the cookie into the it variable)