You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is not easy without import more code from LuaSocket.
LuaSec use the "create" parameter on http.request(). The problem is: "create" does not inform if you will connect with a host using http or https.
If you connect to a host using https and you receive a redirect "http://...", it will break, because LuaSec's "create" only create ssl/tls connections.
Music Man almost forgot escape go back to you in a 51
On Mar 12, 2015 9:47 PM, "Bruno Silvestre" notifications@github.com wrote:
It is not easy without import more code from LuaSocket.
LuaSec use the "create" parameter on http.request(). The problem is:
"create" does not inform if you will connect with a host using http or
https.
If you connect to a host using https and you receive a redirect "http://...",
it will break, because LuaSec's "create" only create ssl/tls connections.
Coding the solution isn't the biggest problem I think. My concerns are about redirects that reduce security. I think that a redirect from https://... to http://... should not be allowed.
I don't know security that well, but I can also imagine a redirect that still is https://..., but has a lesser level of security, flawed algorithm, or lesser bits encryption, should also not be allowed. Or at least controllable by the user.
I can confirm the problem (after testing the simple example). But it is not related to the problem I identified in #35.
Internally the same create function is used twice, and it uses the same table with ssl parameters for creating the context etc.. But the second one fails with an internal LuaSec error; wrong version number. For all I can see this very much looks like a bug... maybe @brunoos can shed some light on this.
Finally had some time to sort this one out. The problem was not with LuaSec. The redirect url, doesn't have a port number. So the default LuaSocket behaviour is to insert port 80. Which obviously fails with a https call.
Activity
brunoos commentedon Mar 12, 2015
It is not easy without import more code from LuaSocket.
LuaSec use the "create" parameter on http.request(). The problem is: "create" does not inform if you will connect with a host using http or https.
If you connect to a host using https and you receive a redirect "http://...", it will break, because LuaSec's "create" only create ssl/tls connections.
https://github.com/diegonehab/luasocket/blob/master/src/http.lua#L109
In order to work, LuaSocket must give more information to "create" as parameter, or LuaSec import the code that detects redirect from LuaSocket.
https://github.com/diegonehab/luasocket/blob/master/src/http.lua#L320
mkottman commentedon Mar 12, 2015
Music Man almost forgot escape go back to you in a 51
On Mar 12, 2015 9:47 PM, "Bruno Silvestre" notifications@github.com wrote:
Tieske commentedon Mar 13, 2015
Coding the solution isn't the biggest problem I think. My concerns are about redirects that reduce security. I think that a redirect from
https://...tohttp://...should not be allowed.I don't know security that well, but I can also imagine a redirect that still is
https://..., but has a lesser level of security, flawed algorithm, or lesser bits encryption, should also not be allowed. Or at least controllable by the user.Tieske commentedon Mar 13, 2015
See lunarmodules/luasocket#133 for a fix to allow redirecting over protocols.
yagop commentedon Mar 13, 2015
I was asking for
https:// -> https://redirections. Nothttps:// -> http://which I think isn't a normal behaviour for servers.Tieske commentedon Mar 13, 2015
The other way around is certainly normal. Anyway, one needs to have them covered.
But as it currently is, the code should allow for redirects https -> https. Did you test before posting this issue?
[-]Support HTTP redirect[/-][+]Support HTTP(S) redirect[/+]yagop commentedon Mar 14, 2015
This is my simple example:
Get
wrong version numberas code.And this is one with options as param:
code is 301, the good part is I can implement the redirection by my own, but it would be nice if the lib do the magic.
Tieske commentedon Mar 15, 2015
I can confirm the problem (after testing the simple example). But it is not related to the problem I identified in #35.
Internally the same
createfunction is used twice, and it uses the same table with ssl parameters for creating the context etc.. But the second one fails with an internal LuaSec error;wrong version number. For all I can see this very much looks like a bug... maybe @brunoos can shed some light on this.Tieske commentedon Mar 23, 2015
Finally had some time to sort this one out. The problem was not with LuaSec. The redirect url, doesn't have a port number. So the default LuaSocket behaviour is to insert port 80. Which obviously fails with a https call.
I think this can be closed in favour of #38.
yagop commentedon Mar 23, 2015
Thanks, great job. 👍