Reputation: 169
In my script, i use the library LuaSocket to send a XML-code. This works fine with the following code:
local request_body = (XMLHeader..XMLBody);
local response_body = {}
local res, code, response_headers = socket.http.request
{
url = "http://blabla.com/v01/Authenticatie.svc";
method = "POST";
headers =
{
["Content-Type"] = "application/soap+xml; charset=utf-8";
["Content-Length"] = string.len(request_body);
["Accept-Encoding"] = "gzip, deflate";
["Connection"] = "Keep-Alive";
};
source = ltn12.source.string(request_body);
sink = ltn12.sink.table(response_body);
}
But now i'll send the XML with the protocoll HTTPS with a certificate. I know that i can use LuaSec but how? Can someone tell me, how i can modify the code to a working code for HTTPS?
Upvotes: 0
Views: 3958
Reputation: 86
Just add:
local https = require("ssl.https")
and replace:
local res, code, response_headers = socket.http.request
with
local res, code, response_headers = https.request
{
url = "https://blabla.com/v01/Authenticatie.svc";
Be sure to have installed LuaSec:
luarocks --local install luasec OPENSSL_LIBDIR=/usr/lib64/ #CentOS
# or
luarocks --local install luasec OPENSSL_LIBDIR=/usr/lib/x86_64-linux-gnu # Ubuntu
Upvotes: 5