diff --git a/lib/resty/etcd/v3.lua b/lib/resty/etcd/v3.lua index b73e5c4c..756f1dbb 100644 --- a/lib/resty/etcd/v3.lua +++ b/lib/resty/etcd/v3.lua @@ -165,6 +165,8 @@ local function http_request_uri(self, http_cli, method, uri, body, headers, keep ssl_verify = self.ssl_verify, ssl_cert_path = self.ssl_cert_path, ssl_key_path = self.ssl_key_path, + ssl_cert = self.ssl_cert, + ssl_key = self.ssl_key, ssl_server_name = self.sni, unix_socket_proxy = self.unix_socket_proxy, }) @@ -436,6 +438,8 @@ function _M.new(opts) ssl_cert_path = opts.ssl_cert_path, ssl_key_path = opts.ssl_key_path, + ssl_cert = opts.ssl_cert, + ssl_key = opts.ssl_key, trusted_ca = opts.trusted_ca, extra_headers = extra_headers, sni = sni, @@ -755,6 +759,8 @@ local function http_request_chunk(self, http_cli) ssl_verify = self.ssl_verify, ssl_cert_path = self.ssl_cert_path, ssl_key_path = self.ssl_key_path, + ssl_cert = self.ssl_cert, + ssl_key = self.ssl_key, ssl_server_name = self.sni, }) if not ok then diff --git a/rockspec/lua-resty-etcd-1.10.5-0.rockspec b/rockspec/lua-resty-etcd-1.10.5-0.rockspec new file mode 100644 index 00000000..979948a3 --- /dev/null +++ b/rockspec/lua-resty-etcd-1.10.5-0.rockspec @@ -0,0 +1,34 @@ +package = "lua-resty-etcd" +version = "1.10.5-0" +source = { + url = "git://github.com/api7/lua-resty-etcd", + tag = "v1.10.5" +} + +description = { + summary = "Nonblocking Lua etcd driver library for OpenResty", + homepage = "https://github.com/api7/lua-resty-etcd", + license = "Apache License 2.0", + maintainer = "Yuansheng Wang " +} + +dependencies = { + "api7-lua-resty-http = 0.2.2-0", + "lua-protobuf = 0.4.1", + "luafilesystem = 1.7.0-2", + "penlight = 1.9.2-1", + "lua-typeof = 0.1" +} + +build = { + type = "builtin", + modules = { + ["resty.etcd"] = "lib/resty/etcd.lua", + ["resty.etcd.v3"] = "lib/resty/etcd/v3.lua", + ["resty.etcd.proto"] = "lib/resty/etcd/proto.lua", + ["resty.etcd.utils"] = "lib/resty/etcd/utils.lua", + ["resty.etcd.serializers.json"] = "lib/resty/etcd/serializers/json.lua", + ["resty.etcd.serializers.raw"] = "lib/resty/etcd/serializers/raw.lua", + ["resty.etcd.health_check"] = "lib/resty/etcd/health_check.lua", + } +} diff --git a/rockspec/lua-resty-etcd-master-0.1-0.rockspec b/rockspec/lua-resty-etcd-master-0.1-0.rockspec index af1e55a4..8029bb24 100644 --- a/rockspec/lua-resty-etcd-master-0.1-0.rockspec +++ b/rockspec/lua-resty-etcd-master-0.1-0.rockspec @@ -13,7 +13,7 @@ description = { } dependencies = { - "api7-lua-resty-http = 0.1.0", + "api7-lua-resty-http = 0.2.2-0", "lua-protobuf = 0.4.1", "luafilesystem = 1.7.0-2", "penlight = 1.9.2-1", diff --git a/t/v3/mtls.t b/t/v3/mtls.t index 8237128f..ae04da78 100644 --- a/t/v3/mtls.t +++ b/t/v3/mtls.t @@ -56,6 +56,21 @@ my $http_config = <<'_EOC_'; ssl_key_path = ssl_key_path or "t/certs/mtls_client.key", }) end + + function new_etcd_ssl_content(ssl_verify, ssl_cert, ssl_key) + return require "resty.etcd" .new({ + protocol = "v3", + api_prefix = "/v3", + http_host = { + "https://127.0.0.1:12379", + "https://127.0.0.1:22379", + "https://127.0.0.1:32379", + }, + ssl_verify = ssl_verify, + ssl_cert = ssl_cert, + ssl_key = ssl_key, + }) + end } _EOC_ @@ -79,7 +94,71 @@ run_tests(); __DATA__ -=== TEST 1: TLS no verify +=== TEST 1: TLS no verify with TLS content +--- config + location /t { + content_by_lua_block { + local cert = [[-----BEGIN CERTIFICATE----- +MIIDOjCCAiICAwD6zzANBgkqhkiG9w0BAQsFADBnMQswCQYDVQQGEwJjbjESMBAG +A1UECAwJR3VhbmdEb25nMQ8wDQYDVQQHDAZaaHVIYWkxDTALBgNVBAoMBGFwaTcx +DDAKBgNVBAsMA29wczEWMBQGA1UEAwwNY2EuYXBpc2l4LmRldjAeFw0yMDA2MjAx +M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vb/TEidCkfcf +zg/pTcGf2My0MiJLk47xO6EgzNdso9mMG5ZYPraBBsuo7NupvWxCp7NyCiOJDqGH +K5NmhjInjzsjTghIQRq5+qcCgYEAxnm/NjjvslL8F69p/I3cDJ2/RpaG0sMXvbrO +VWaMryQyWGz9OfNgGIbeMu2Jj90dar6ChcfUmb8lGOi2AZl/VGmc/jqaMKFnElHl +J5JyMFicUzPMiG8DBH+gB71W4Iy+BBKwugHBQP2hkytewQ++PtKuP+RjADEz6vCN +0mv0WS8CgYBnbMRP8wIOLJPRMw/iL9BdMf606X4xbmNn9HWVp2mH9D3D51kDFvls +7y2vEaYkFv3XoYgVN9ZHDUbM/YTUozKjcAcvz0syLQb8wRwKeo+XSmo09+360r18 +zRugoE7bPl39WdGWaW3td0qf1r9z3sE2iWUTJPRQ3DYpsLOYIgyKmw== +-----END RSA PRIVATE KEY-----]] + local etcd, err = new_etcd_ssl_content(false, cert, pkey) + check_res(etcd, err) + + local res, err = etcd:set("/test", { a='aaa'}) + check_res(res, err) + ngx.say("done") + } + } +--- response_body +done + + + +=== TEST 2: TLS no verify --- config location /t { content_by_lua_block { @@ -96,7 +175,7 @@ done -=== TEST 2: TLS verify +=== TEST 3: TLS verify --- config location /t { content_by_lua_block { @@ -113,7 +192,7 @@ unable to get local issuer certificate -=== TEST 3: watch +=== TEST 4: watch --- config location /t { content_by_lua_block { @@ -157,7 +236,7 @@ timeout/ -=== TEST 4: bad client certificate +=== TEST 5: bad client certificate --- config location /t { content_by_lua_block { @@ -173,3 +252,164 @@ timeout/ bad certificate --- response_body_like handshake failed + + + +=== TEST 6: bad client certificate wtih ssl content +--- config + location /t { + content_by_lua_block { + local cert = [[-----BEGIN CERTIFICATE----- +MIIDrzCCApegAwIBAgIJAI3Meu/gJVTLMA0GCSqGSIb3DQEBCwUAMG4xCzAJBgNV +BAYTAkNOMREwDwYDVQQIDAhaaGVqaWFuZzERMA8GA1UEBwwISGFuZ3pob3UxDTAL +BgNVBAoMBHRlc3QxDT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/Y0oMz7bSruE5Z8 +g0VOHPkSr4XiYgLpQxjbNjq8fwsa/jTt1B57+By4xLpZYD0BTFuf5po+igSZhH8s +QS5XnUnbM7d6Xr/da7ZkhSmUbEaMeHONSIVpYNgtRo4bB9Mh0l1HWdoevw/w5Ryt +L/OQiPhfLQKBgQCh1iG1fPh7bbnVe/HI71iL58xoPbCwMLEFIjMiOFcINirqCG6V +LR91Ytj34JCihl1G4/TmWnsH1hGIGDRtJLCiZeHL70u32kzCMkI1jOhFAWqoutMa +7obDkmwraONIVW/kFp6bWtSJhhTQTD4adI9cPCKWDXdcCHSWj0Xk+U8HgQKBgBng +t1HYhaLzIZlP/U/nh3XtJyTrX7bnuCZ5FhKJNWrYjxAfgY+NXHRYCKg5x2F5j70V +be7pLhxmCnrPTMKZhik56AaTBOxVVBaYWoewhUjV4GRAaK5Wc8d9jB+3RizPFwVk +V3OU2DJ1SNZ+W2HBOsKrEfwFF/dgby6i2w6MuAP1AoGBAIxvxUygeT/6P0fHN22P +zAHFI4v2925wYdb7H//D8DIADyBwv18N6YH8uH7L+USZN7e4p2k8MGGyvTXeC6aX +IeVtU6fH57Ddn59VPbF20m8RCSkmBvSdcbyBmqlZSBE+fKwCliKl6u/GH0BNAWKz +r8yiEiskqRmy7P7MY9hDmEbG +-----END PRIVATE KEY-----]] + + local etcd, err = new_etcd_ssl_content(false, cert, pkey) + check_res(etcd, err) + + local res, err = etcd:set("/test", { a='abc'}) + check_res(res, err) + ngx.say("done") + } + } +--- error_log +bad certificate +--- response_body_like +handshake failed + + + +=== TEST 7: watch by ssl content +--- config + location /t { + content_by_lua_block { + local cert = [[-----BEGIN CERTIFICATE----- +MIIDOjCCAiICAwD6zzANBgkqhkiG9w0BAQsFADBnMQswCQYDVQQGEwJjbjESMBAG +A1UECAwJR3VhbmdEb25nMQ8wDQYDVQQHDAZaaHVIYWkxDTALBgNVBAoMBGFwaTcx +DDAKBgNVBAsMA29wczEWMBQGA1UEAwwNY2EuYXBpc2l4LmRldj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H6/aOL8V9ogwwZuIvb/TEidCkfcf +zg/pTcGf2My0MiJLk47xO6EgzNdso9mMG5ZYPraBBsuo7NupvWxCp7NyCiOJDqGH +K5NmhjInjzsjTghIQRq5+qcCgYEAxnm/NjjvslL8F69p/I3cDJ2/RpaG0sMXvbrO +VWaMryQyWGz9OfNgGIbeMu2Jj90dar6ChcfUmb8lGOi2AZl/VGmc/jqaMKFnElHl +J5JyMFicUzPMiG8DBH+gB71W4Iy+BBKwugHBQP2hkytewQ++PtKuP+RjADEz6vCN +0mv0WS8CgYBnbMRP8wIOLJPRMw/iL9BdMf606X4xbmNn9HWVp2mH9D3D51kDFvls +7y2vEaYkFv3XoYgVN9ZHDUbM/YTUozKjcAcvz0syLQb8wRwKeo+XSmo09+360r18 +zRugoE7bPl39WdGWaW3td0qf1r9z3sE2iWUTJPRQ3DYpsLOYIgyKmw== +-----END RSA PRIVATE KEY-----]] + local etcd, err = new_etcd_ssl_content(false, cert, pkey) + check_res(etcd, err) + + local res, err = etcd:set("/test", "abc") + check_res(res, err) + + ngx.timer.at(0.1, function () + etcd:set("/test", "bcd3") + end) + + local cur_time = ngx.now() + local body_chunk_fun, err = etcd:watch("/test", {timeout = 0.5}) + if not body_chunk_fun then + ngx.say("failed to watch: ", err) + end + + local idx = 0 + while true do + local chunk, err = body_chunk_fun() + + if not chunk then + if err then + ngx.say(err) + end + break + end + + idx = idx + 1 + ngx.say(idx, ": ", require("cjson").encode(chunk.result)) + end + } + } +--- response_body_like eval +qr/1:.*"created":true.* +2:.*"value":"bcd3".* +timeout/ +--- timeout: 5