Skip to content

Commit d2944a1

Browse files
author
mengxiangwei
committed
feat: add server random and master key fetch api
1 parent cac9cbc commit d2944a1

5 files changed

Lines changed: 1811 additions & 0 deletions

File tree

‎.vscode/c_cpp_properties.json‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "macos-clang-x64",
5+
"includePath": [
6+
"${workspaceFolder}/**"
7+
],
8+
"compilerPath": "/usr/local/opt/llvm/bin/clang",
9+
"cStandard": "${default}",
10+
"cppStandard": "${default}",
11+
"intelliSenseMode": "macos-clang-x64",
12+
"compilerArgs": [
13+
""
14+
]
15+
}
16+
],
17+
"version": 4
18+
}

‎.vscode/launch.json‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "C/C++ Runner: Debug Session",
6+
"type": "lldb",
7+
"request": "launch",
8+
"args": [],
9+
"cwd": "/Users/xiangwei/Desktop/theweakgod/lua-nginx-module/src",
10+
"program": "/Users/xiangwei/Desktop/theweakgod/lua-nginx-module/src/build/Debug/outDebug"
11+
}
12+
]
13+
}

‎.vscode/settings.json‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"C_Cpp_Runner.cCompilerPath": "clang",
3+
"C_Cpp_Runner.cppCompilerPath": "clang++",
4+
"C_Cpp_Runner.debuggerPath": "lldb",
5+
"C_Cpp_Runner.cStandard": "",
6+
"C_Cpp_Runner.cppStandard": "",
7+
"C_Cpp_Runner.msvcBatchPath": "",
8+
"C_Cpp_Runner.useMsvc": false,
9+
"C_Cpp_Runner.warnings": [
10+
"-Wall",
11+
"-Wextra",
12+
"-Wpedantic",
13+
"-Wshadow",
14+
"-Wformat=2",
15+
"-Wcast-align",
16+
"-Wconversion",
17+
"-Wsign-conversion",
18+
"-Wnull-dereference"
19+
],
20+
"C_Cpp_Runner.msvcWarnings": [
21+
"/W4",
22+
"/permissive-",
23+
"/w14242",
24+
"/w14287",
25+
"/w14296",
26+
"/w14311",
27+
"/w14826",
28+
"/w44062",
29+
"/w44242",
30+
"/w14905",
31+
"/w14906",
32+
"/w14263",
33+
"/w44265",
34+
"/w14928"
35+
],
36+
"C_Cpp_Runner.enableWarnings": true,
37+
"C_Cpp_Runner.warningsAsError": false,
38+
"C_Cpp_Runner.compilerArgs": [],
39+
"C_Cpp_Runner.linkerArgs": [],
40+
"C_Cpp_Runner.includePaths": [],
41+
"C_Cpp_Runner.includeSearch": [
42+
"*",
43+
"**/*"
44+
],
45+
"C_Cpp_Runner.excludeSearch": [
46+
"**/build",
47+
"**/build/**",
48+
"**/.*",
49+
"**/.*/**",
50+
"**/.vscode",
51+
"**/.vscode/**"
52+
],
53+
"C_Cpp_Runner.useAddressSanitizer": false,
54+
"C_Cpp_Runner.useUndefinedSanitizer": false,
55+
"C_Cpp_Runner.useLeakSanitizer": false,
56+
"C_Cpp_Runner.showCompilationTime": false,
57+
"C_Cpp_Runner.useLinkTimeOptimization": false,
58+
"C_Cpp_Runner.msvcSecureNoWarnings": false,
59+
"files.associations": {
60+
"*.lua": "lua",
61+
"__hash_table": "c",
62+
"__split_buffer": "c",
63+
"array": "c",
64+
"bitset": "c",
65+
"deque": "c",
66+
"initializer_list": "c",
67+
"queue": "c",
68+
"stack": "c",
69+
"string": "c",
70+
"string_view": "c",
71+
"unordered_map": "c",
72+
"vector": "c"
73+
}
74+
}

‎src/ngx_http_lua_ssl_certby.c‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,4 +1754,53 @@ ngx_http_lua_ffi_ssl_client_random(ngx_http_request_t *r,
17541754
}
17551755

17561756

1757+
int
1758+
ngx_http_lua_ffi_ssl_server_random(ngx_http_request_t *r,
1759+
unsigned char *out, size_t *outlen, char **err)
1760+
{
1761+
ngx_ssl_conn_t *ssl_conn;
1762+
1763+
if (r->connection == NULL || r->connection->ssl == NULL) {
1764+
*err = "bad request";
1765+
return NGX_ERROR;
1766+
}
1767+
1768+
ssl_conn = r->connection->ssl->connection;
1769+
if (ssl_conn == NULL) {
1770+
*err = "bad ssl conn";
1771+
return NGX_ERROR;
1772+
}
1773+
1774+
*outlen = SSL_get_server_random(ssl_conn, out, *outlen);
1775+
1776+
return NGX_OK;
1777+
}
1778+
1779+
int
1780+
ngx_http_lua_ffi_ssl_session_master_key(ngx_http_request_t *r,
1781+
unsigned char *out, size_t *outlen, char **err)
1782+
{
1783+
ngx_ssl_conn_t *ssl_conn;
1784+
SSL_SESSION *sess;
1785+
1786+
if (r->connection == NULL || r->connection->ssl == NULL) {
1787+
*err = "bad request";
1788+
return NGX_ERROR;
1789+
}
1790+
1791+
ssl_conn = r->connection->ssl->connection;
1792+
if (ssl_conn == NULL) {
1793+
*err = "bad ssl conn";
1794+
return NGX_ERROR;
1795+
}
1796+
1797+
sess = SSL_get0_session(ssl_conn);
1798+
1799+
1800+
*outlen = SSL_SESSION_get_master_key(sess, out, *outlen);
1801+
1802+
return NGX_OK;
1803+
}
1804+
1805+
17571806
#endif /* NGX_HTTP_SSL */

0 commit comments

Comments
 (0)