summaryrefslogtreecommitdiffhomepage
path: root/libs/px5g/lua
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/lua
parent4934c979788a7da5a68c6a21b89734e20b5044a5 (diff)
nixio: Add support for DER certificates, PX5G fix Certmaster
Diffstat (limited to 'libs/px5g/lua')
-rw-r--r--libs/px5g/lua/px5g/util.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/libs/px5g/lua/px5g/util.lua b/libs/px5g/lua/px5g/util.lua
index e94fb65076..0f07c81b8c 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