summaryrefslogtreecommitdiffhomepage
path: root/libs/px5g
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2009-06-07 10:15:12 +0000
committerSteven Barth <steven@midlink.org>2009-06-07 10:15:12 +0000
commit0ebce1d6088a3a503ab038fd5ab81357ccabe625 (patch)
tree94027dc509d18c6f11aaf52130c9a2a668edfd71 /libs/px5g
parent4934c979788a7da5a68c6a21b89734e20b5044a5 (diff)
nixio: Add support for DER certificates, PX5G fix Certmaster
Diffstat (limited to 'libs/px5g')
-rw-r--r--libs/px5g/lua/px5g/util.lua7
-rwxr-xr-xlibs/px5g/root/usr/sbin/px5g-genkeys1
-rw-r--r--libs/px5g/src/px5g.c9
3 files changed, 12 insertions, 5 deletions
diff --git a/libs/px5g/lua/px5g/util.lua b/libs/px5g/lua/px5g/util.lua
index e94fb6507..0f07c81b8 100644
--- a/libs/px5g/lua/px5g/util.lua
+++ b/libs/px5g/lua/px5g/util.lua
@@ -29,7 +29,7 @@ function der2pem(data, type)
local b64 = nixio.bin.b64encode(data)
local outdata = {preamble[type]}
- for i = 1, 64, #b64 + 63 do
+ for i = 1, #b64, 64 do
outdata[#outdata + 1] = b64:sub(i, i + 63)
end
outdata[#outdata + 1] = postamble[type]
@@ -37,3 +37,8 @@ function der2pem(data, type)
return table.concat(outdata, "\n")
end
+
+function pem2der(data)
+ local b64 = data:gsub({["\n"] = "", ["%-%-%-%-%-.-%-%-%-%-%-"] = ""})
+ return nixio.bin.b64decode(b64)
+end \ No newline at end of file
diff --git a/libs/px5g/root/usr/sbin/px5g-genkeys b/libs/px5g/root/usr/sbin/px5g-genkeys
index 29906577f..87a66bfe2 100755
--- a/libs/px5g/root/usr/sbin/px5g-genkeys
+++ b/libs/px5g/root/usr/sbin/px5g-genkeys
@@ -6,6 +6,7 @@ local px5g = require "px5g"
local nixio = require "nixio"
local fs = require "nixio.fs"
local os = require "os"
+nixio.umask(77)
if not fs.access(certfile) then
local key = px5g.genkey(2048)
diff --git a/libs/px5g/src/px5g.c b/libs/px5g/src/px5g.c
index 20ae7957f..feecd0127 100644
--- a/libs/px5g/src/px5g.c
+++ b/libs/px5g/src/px5g.c
@@ -85,21 +85,22 @@ static int px5g_rsa_create_selfsigned(lua_State *L) {
strftime(tstr, sizeof(tstr), "%F %H:%M:%S", gmtime(&to)),
4, "Invalid Time");
+ size_t join = 1;
lua_pushliteral(L, "");
for (int i = 0; i < (sizeof(xfields) / sizeof(*xfields)); i++) {
lua_pushstring(L, xfields[i]);
lua_rawget(L, 2);
if (lua_isstring(L, -1)) {
const char *val = lua_tostring(L, -1);
- luaL_argcheck(L, !strchr(val, '\''), 2, "Invalid Value");
- lua_pushfstring(L, "%s%s='%s';",
- lua_tostring(L, -2), xfields[i], val);
- lua_remove(L, -2);
+ luaL_argcheck(L, !strchr(val, ';'), 2, "Invalid Value");
+ lua_pushfstring(L, "%s=%s;", xfields[i], val);
lua_remove(L, -2);
+ join++;
} else {
lua_pop(L, 1);
}
}
+ lua_concat(L, join);
x509_raw cert;
x509write_init_raw(&cert);