lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi

Thanks Paul and everyone that helped with suggestions. After a fair bit of struggle I got it working.  Ad hoc and messy process I know, but at least it worked.

I didnt really like any of those solutions, none were straightforward. For the average Joe Win programmer like me, I dont like the LuaDist type solution of download all the dependency sources and download mingw and compile ourselves.  Too much hassle and too many things likely to trip you up.

For anyone that struggles with this in the future, here is exactly what I did to get luasec/SSL working  (I am using Lua 5.1 and Win7 64 Bit for reference)

I am using LuaSocket 2.0.2 from an earlier LuaForWindows Install
Downloaded Luasec 0.5 from Github

Refer to this page to get the Windows Luasec binaries.          https://love2d.org/forums/viewtopic.php?f=5&t=76728&p=159477&hilit=linux+binary
I  chose Windows x86 (32-bit) 

 Copied the 'ssl.lua' file to a folder in my LUA_PATH.
 Copied the 'ssl.dll' file to a folder in  my LUA_CPATH.
 Created a directory 'ssl' in my LUA_PATH and copied 'https.lua' to it.

Tested it with this code
-----------------------------------------------------------------------------------------------------------------------
require("socket")
local https = require("ssl.https")

local body, code, headers, status = https.request("https://en.wikipedia.org/wiki/HTTPS";)
print(body, code, headers, status)
-----------------------------------------------------------------------------------------------------------------------

I got a Window dialogue box pop up with a fairly obscure sounding error. Forget the exact wording, something like

"The ordinal 350 could not be located in the dynamic link library SSLEAY32.dll"

That one had me foxed for a while, but found an article.  http://www.techchattr.com/openssl-working-windows-ssleay32-dll-error

As the article points out the error was due to the version of openSSL that ships and installs with WAMP.
(I had installed WAMP on my PC some time ago)

So then went to this page    http://slproweb.com/products/Win32OpenSSL.html

and downloaded and installed   Win32 OpenSSL v1.0.2d

That fixed the problem, I can now download https pages successfully.

My code to get the live football scores from the Betfair page is not working but thats just some html parsing logic problem I daresay.
I should be able to debug that and get it working tomorrow with some assistance from Zerobrane Studio.

Hey Paul, you should try Zerobrane Studio, its excellent and very helpful at  bug finding !  :)

Regards Geoff

________________________________________
From: lua-l-bounces@lists.lua.org <lua-l-bounces@lists.lua.org> on behalf of Paul K <paul@zerobrane.com>
Sent: 24 November 2015 22:03
To: Lua mailing list
Subject: Re: How to get a webpage with Lua Socket ?

Hi Geoff,

> This library doesnt appear to have a windows binary available.  So I have to build it myself, with not very good build notes.
> I wonder if I could  snag the luasec  *.lua files and *.dll file I need from my  Zerobrane Studio installation ? That might be a simpler solution ?

Yes, you should be able to get all the files including the binary from
this commit: https://github.com/pkulchenko/ZeroBraneStudio/commit/0d8e6b058186fb361680ed05ff8dceec5123c70c.
The DLL is no longer packaged with the IDE, but you can still get it
from the archive. Note that you still need openssl libraries installed
and referenced in PATH, but they come with many applications, like
wget, svn, and others.

Another option is to compile luasec using the build scripts from ZBS.
You'll need to pull the latest changes from the repository and then
run "(cd build; bash build-win32.sh lua luasec)". This should build
and install ssl.dll in the right place under ZBS tree (and it will
include all the dependencies) as long as you have mingw/msys or tdm
installed.

Yet another option is to try luarocks or luadist
(https://github.com/LuaDist/luasec/releases/tag/0.4-Windows-x86);
you'd still need openssl libraries and headers though.

Paul.