-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from thibaultCha/feature/ssl
[feature] TLS support for luasocket + nginx cosocket API
- Loading branch information
Showing
16 changed files
with
267 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
-------- | ||
-- Example of SSL enabled connection using luasocket | ||
|
||
local cassandra = require "cassandra" | ||
local PasswordAuthenticator = require "cassandra.authenticators.PasswordAuthenticator" | ||
|
||
local session = cassandra:new() | ||
local auth = PasswordAuthenticator("cassandra", "cassandra") | ||
|
||
local ok, err = session:connect({"x.x.x.x", "y.y.y.y"}, nil, { | ||
authenticator = auth, | ||
ssl = true, | ||
ssl_verify = true, | ||
ca_file = "/path/to/your/ca-certificate.pem" | ||
}) | ||
if not ok then | ||
print(err.message) | ||
end | ||
|
||
local res, err = session:execute("SELECT * FROM system_auth.users") | ||
|
||
-------- | ||
-- Example of SSL enabled connection from nginx | ||
|
||
worker_processes 1; | ||
error_log logs/error.log; | ||
events { | ||
worker_connections 1024; | ||
} | ||
http { | ||
server { | ||
listen 8080; | ||
location / { | ||
lua_ssl_trusted_certificate "/path/to/your/ca-certificate.pem"; | ||
default_type text/html; | ||
content_by_lua ' | ||
local cassandra = require "cassandra" | ||
local PasswordAuthenticator = require "cassandra.authenticators.PasswordAuthenticator" | ||
|
||
local session = cassandra:new() | ||
local auth = PasswordAuthenticator("cassandra", "cassandra") | ||
|
||
local ok, err = session:connect({"x.x.x.x", "y.y.y.y"}, nil, { | ||
authenticator = auth, | ||
ssl = true, | ||
ssl_verify = true | ||
}) | ||
if not ok then | ||
ngx.log(ngx.ERR, err.message) | ||
end | ||
|
||
local res, err = session:execute("SELECT * FROM system_auth.users") | ||
'; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
<html> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> | ||
<head> | ||
<title>lua-cassandra documentation</title> | ||
<link rel="stylesheet" href="../ldoc_pale.css" type="text/css" /> | ||
</head> | ||
<body> | ||
|
||
<div id="container"> | ||
|
||
<div id="product"> | ||
<div id="product_logo"></div> | ||
<div id="product_name"><big><b></b></big></div> | ||
<div id="product_description"></div> | ||
</div> <!-- id="product" --> | ||
|
||
|
||
<div id="main"> | ||
|
||
|
||
<!-- Menu --> | ||
|
||
<div id="navigation"> | ||
<br/> | ||
<h1>lua-cassandra</h1> | ||
|
||
<ul> | ||
<li><a href="../index.html">Index</a></li> | ||
</ul> | ||
|
||
|
||
|
||
<h2>Examples</h2> | ||
<ul class="$(kind=='Topics' and '' or 'nowrap'"> | ||
<li><a href="../examples/authentication.lua.html">authentication.lua</a></li> | ||
<li><a href="../examples/basic.lua.html">basic.lua</a></li> | ||
<li><a href="../examples/batch.lua.html">batch.lua</a></li> | ||
<li><a href="../examples/pagination.lua.html">pagination.lua</a></li> | ||
<li><strong>ssl.lua</strong></li> | ||
</ul> | ||
<h2>Modules</h2> | ||
<ul class="$(kind=='Topics' and '' or 'nowrap'"> | ||
<li><a href="../modules/Cassandra.html">Cassandra</a></li> | ||
<li><a href="../modules/PasswordAuthenticator.html">PasswordAuthenticator</a></li> | ||
<li><a href="../modules/BatchStatement.html">BatchStatement</a></li> | ||
<li><a href="../modules/Error.html">Error</a></li> | ||
<li><a href="../modules/Session.html">Session</a></li> | ||
</ul> | ||
<h2>Manual</h2> | ||
<ul class="$(kind=='Topics' and '' or 'nowrap'"> | ||
<li><a href="../manual/README.md.html">README</a></li> | ||
</ul> | ||
|
||
</div> | ||
|
||
<div id="content"> | ||
|
||
<h2>ssl.lua</h2> | ||
<pre> | ||
<span class="comment">-------- | ||
</span><span class="comment">-- Example of SSL enabled connection using luasocket | ||
</span> | ||
<span class="keyword">local</span> cassandra = <span class="global">require</span> <span class="string">"cassandra"</span> | ||
<span class="keyword">local</span> PasswordAuthenticator = <span class="global">require</span> <span class="string">"cassandra.authenticators.PasswordAuthenticator"</span> | ||
|
||
<span class="keyword">local</span> session = cassandra:new() | ||
<span class="keyword">local</span> auth = PasswordAuthenticator(<span class="string">"cassandra"</span>, <span class="string">"cassandra"</span>) | ||
|
||
<span class="keyword">local</span> ok, err = session:connect({<span class="string">"x.x.x.x"</span>, <span class="string">"y.y.y.y"</span>}, <span class="keyword">nil</span>, { | ||
authenticator = auth, | ||
ssl = <span class="keyword">true</span>, | ||
ssl_verify = <span class="keyword">true</span>, | ||
ca_file = <span class="string">"/path/to/your/ca-certificate.pem"</span> | ||
}) | ||
<span class="keyword">if</span> <span class="keyword">not</span> ok <span class="keyword">then</span> | ||
<span class="global">print</span>(err.message) | ||
<span class="keyword">end</span> | ||
|
||
<span class="keyword">local</span> res, err = session:execute(<span class="string">"SELECT * FROM system_auth.users"</span>) | ||
|
||
<span class="comment">-------- | ||
</span><span class="comment">-- Example of SSL enabled connection from nginx | ||
</span> | ||
worker_processes <span class="number">1</span>; | ||
error_log logs/error.log; | ||
events { | ||
worker_connections <span class="number">1024</span>; | ||
} | ||
http { | ||
server { | ||
listen <span class="number">8080</span>; | ||
location / { | ||
lua_ssl_trusted_certificate <span class="string">"/path/to/your/ca-certificate.pem"</span>; | ||
default_type text/html; | ||
content_by_lua <span class="string">' | ||
local cassandra = require "cassandra" | ||
local PasswordAuthenticator = require "cassandra.authenticators.PasswordAuthenticator" | ||
|
||
local session = cassandra:new() | ||
local auth = PasswordAuthenticator("cassandra", "cassandra") | ||
|
||
local ok, err = session:connect({"x.x.x.x", "y.y.y.y"}, nil, { | ||
authenticator = auth, | ||
ssl = true, | ||
ssl_verify = true | ||
}) | ||
if not ok then | ||
ngx.log(ngx.ERR, err.message) | ||
end | ||
|
||
local res, err = session:execute("SELECT * FROM system_auth.users") | ||
'</span>; | ||
} | ||
} | ||
}</pre> | ||
|
||
|
||
</div> <!-- id="content" --> | ||
</div> <!-- id="main" --> | ||
<div id="about"> | ||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> | ||
<i style="float:right;">Last updated 2015-07-10 00:32:25 </i> | ||
</div> <!-- id="about" --> | ||
</div> <!-- id="container" --> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.