lua-users home
lua-l archive

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


I just subscribed so I can't continue the thread "Q: luasocket https
client?" started on 2009-02-13.  I faced the same problem some time back
(actually for allowing HTTPS SOAP calls), but I added an optional
parameter to

function open(host, port, create, security_context)
    -- create socket with user connect function, or with default
    local c = socket.try((create or socket.tcp)())
    local h = base.setmetatable({ c = c }, metat)
    -- create finalized try
    h.try = socket.newtry(function() h:close() end)
    -- set timeout before connecting
    h.try(c:connect(host, port or PORT))
    if security_context then
       h.c = h.try(ssl.wrap(c, security_context))
    -- here everything worked
    return h

security_context id the normal context passed to ssl.wrap

This way I can make both HTTP and HTTPS calls.