Skip to content

Commit

Permalink
lib: tls: add error handling for missing servername
Browse files Browse the repository at this point in the history
when writing test-tls-client-reject I was hitting the low level
tls_binding:connect code error handling which isn't very pretty. Print a
nicer message from lua.
  • Loading branch information
Brandon Philips committed Apr 30, 2012
1 parent ccd0e8f commit fc64964
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/luvit/tls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,9 @@ function SecurePair:initialize(credentials, isServer, requestCert, rejectUnautho
if self._isServer == true then
certOrServerName = self._requestCert
else
if not options.servername then
error('servername is a required parameter')
end
certOrServerName = options.servername
end

Expand Down Expand Up @@ -824,8 +827,12 @@ function connect(...)

socket:connect(options.port, options.host)

local servername = options.servername or options.host
if not servername then
error('host is a required parameter')
end
local pair = SecurePair:new(sslcontext, false, true, options.rejectUnauthorized == true, {
servername = options.servername or options.host,
servername = servername
})

if options.session then
Expand Down

0 comments on commit fc64964

Please sign in to comment.