3

I am trying to use the curl library in a little lua script.

I know there is a "-k" option to disable the certification verification that curl does by default... but I haven't been able to find how to do it via code.

here's what I have so far:

  local cURL = require("cURL")

    headers = {"Accept: text/*",
               "Accept-Language: en",
               "Accept-Charset: iso-8859-1,*,utf-8",
               "Cache-Control: no-cache"}
    login_url = "https://10.10.2.1/cgi-bin/acd/myapp/controller/method?userid=tester&password=123123"

    c = cURL.easy_init()
    c:setopt_url(login_url)

    c:perform({writefunction=function(str)
                                succeed = succeed or (string.find(str, "srcId:%s+SignInAlertSupressor--"))
                             end }) 

Thanks for your time.

2 Answers 2

1

With new version of Lua-cURL[1] you can write

local cURL = require("cURL")

headers = {
  "Accept: text/*",
  "Accept-Language: en",
  "Accept-Charset: iso-8859-1,*,utf-8",
  "Cache-Control: no-cache"
}

login_url = "https://10.10.2.1/cgi-bin/acd/myapp/controller/method?userid=tester&password=123123"

c = cURL.easy{
  url            = login_url,
  ssl_verifypeer = false,
  ssl_verifyhost = false,
  httpheader     = headers,
  writefunction  = function(str)
    succeed = succeed or (string.find(str, "srcId:%s+SignInAlertSupressor--"))
  end
}

c:perform()

1 - https://github.com/Lua-cURL/Lua-cURLv3

Sign up to request clarification or add additional context in comments.

Comments

0

I don't know much about lua and the corresponding cURL implementation. But to disable the SSL verification you need to set these options

CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST

And in lua i think you can set it using,

c:setopt(CURLOPT_SSL_VERIFYPEER , false)
c:setopt(CURLOPT_SSL_VERIFYHOST , false) 

1 Comment

I'll have to hunt around because c:setopt() doesn't seem to work. It returns an error message "attempt to call method 'setopt' (a nil value)'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.