net.http: Add option for disabling TLS certifictate validation
authorKim Alvefur <zash@zash.se>
Fri, 07 Jul 2017 21:04:46 +0200
changeset 8203 e92585ab4998
parent 8202 8f82d3cd0631
child 8204 a0ad62a269df
child 8205 85a60e863509
net.http: Add option for disabling TLS certifictate validation
net/http.lua
--- a/net/http.lua	Fri Jul 07 21:04:30 2017 +0200
+++ b/net/http.lua	Fri Jul 07 21:04:46 2017 +0200
@@ -37,7 +37,7 @@
 	local req = requests[conn];
 
 	-- Validate certificate
-	if conn:ssl() then
+	if not req.insecure and conn:ssl() then
 		local sock = conn:socket();
 		local chain_valid = sock.getpeerverification and sock:getpeerverification();
 		if not chain_valid then
@@ -202,6 +202,7 @@
 				headers[k] = v;
 			end
 		end
+		req.insecure = ex.insecure;
 	end
 
 	log("debug", "Making %s %s request '%s' to %s", req.scheme:upper(), method or "GET", req.id, (ex and ex.suppress_url and host_header) or u);