---@meta ssl.context

--------------------------------------------------------------------------------
-- LuaSec SSL context C module
--------------------------------------------------------------------------------

---@class ssl_context*
local ssl_context = {}

---@class ssl_context_core*
---@type ssl_context_core*
local M = {}

--- Create SSL context.
---@param protocol string Protocol, such as any, tls, tlsv1_2, tlsv1_3
---@return ssl_context*? context SSL context
---@return string? errMsg error message
function M.create(protocol) end

--- Load a CA file or directory.
---@param context ssl_context* SSL context
---@param cafile? string CA file path
---@param capath? string CA directory path
---@return boolean ok Is it successful?
---@return string? errMsg error message
function M.locations(context, cafile, capath) end

--- Load the certificate chain file.
---@param context ssl_context* SSL context
---@param filename string Certificate chain file path
---@return boolean ok Is it successful?
---@return string? errMsg error message
function M.loadcert(context, filename) end

--- Load the private key file.
---@param context ssl_context* SSL context
---@param filename string Private key file path
---@param password? string|function Private key password or callback
---@return boolean ok Is it successful?
---@return string? errMsg error message
function M.loadkey(context, filename, password) end

--- Check that the private key and certificate match.
---@param context ssl_context* SSL context
---@return boolean ok Does it match
function M.checkkey(context) end

--- Set ALPN protocol list.
---@param context ssl_context* SSL context
---@param protocols string wire-format ALPN string
---@return boolean ok Is it successful?
---@return string? errMsg error message
function M.setalpn(context, protocols) end

--- Set server-side ALPN callback.
---@param context ssl_context* SSL context
---@param callback function ALPN callback
---@return boolean ok Is it successful?
---@return string? errMsg error message
function M.setalpncb(context, callback) end

--- Set cipher list.
---@param context ssl_context* SSL context
---@param ciphers string cipher list
---@return boolean ok Is it successful?
---@return string? errMsg error message
function M.setcipher(context, ciphers) end

--- Set up TLS 1.3 cipher suites.
---@param context ssl_context* SSL context
---@param ciphersuites string cipher suites
---@return boolean ok Is it successful?
---@return string? errMsg error message
function M.setciphersuites(context, ciphersuites) end

--- Set the certificate verification depth.
---@param context ssl_context* SSL context
---@param depth integer Depth
---@return boolean ok Is it successful?
function M.setdepth(context, depth) end

--- Set DH parameter callback.
---@param context ssl_context* SSL context
---@param callback function DH Parameter callback
---@return boolean ok Is it successful?
function M.setdhparam(context, callback) end

--- Set the certificate verification mode.
---@param context ssl_context* SSL context
---@param ... 'none'|'peer'|'client_once'|'fail_if_no_peer_cert' Validation options
---@return boolean ok Is it successful?
---@return string? errMsg error message
function M.setverify(context, ...) end

--- Set OpenSSL options.
---@param context ssl_context* SSL context
---@param ... string OpenSSL option Name
---@return boolean ok Is it successful?
---@return string? errMsg error message
function M.setoptions(context, ...) end

--- Set context mode.
---@param context ssl_context* SSL context
---@param mode 'client'|'server' mode
---@return boolean ok Is it successful?
---@return string? errMsg error message
function M.setmode(context, mode) end

--- Set elliptic curve.
---@param context ssl_context* SSL context
---@param curve string Curve name
---@return boolean ok Is it successful?
---@return string? errMsg error message
function M.setcurve(context, curve) end

--- Set the elliptic curve list.
---@param context ssl_context* SSL context
---@param curves string Curve list
---@return boolean ok Is it successful?
---@return string? errMsg error message
function M.setcurveslist(context, curves) end

--- Set PSK identity hint.
---@param context ssl_context* SSL context
---@param hint string identity hint
---@return boolean ok Is it successful?
---@return string? errMsg error message
function M.setpskhint(context, hint) end

--- Set server-side PSK callback.
---@param context ssl_context* SSL context
---@param callback function PSK callback
---@return boolean ok Is it successful?
---@return string? errMsg error message
function M.setserverpskcb(context, callback) end

--- Set client PSK callback.
---@param context ssl_context* SSL context
---@param callback function PSK callback
---@return boolean ok Is it successful?
---@return string? errMsg error message
function M.setclientpskcb(context, callback) end

--- Enable DANE.
---@param context ssl_context* SSL context
---@return boolean ok Is it successful?
---@return string? errMsg error message
function M.setdane(context) end

--- Set extended validation options.
---@param ... 'lsec_continue'|'lsec_ignore_purpose'|'crl_check'|'crl_check_chain' Extended validation options
---@return boolean ok Is it successful?
---@return string? errMsg error message
function ssl_context:setverifyext(...) end

return M
