Changeset 4763

Show
Ignore:
Timestamp:
06/07/09 11:15:12 (4 years ago)
Author:
Cyrus
Message:

nixio: Add support for DER certificates, PX5G fix Certmaster

Location:
luci/trunk/libs
Files:
4 added
4 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/libs/nixio/src/tls-context.c

    r4757 r4763  
    114114    SSL_CTX *ctx = nixio__checktlsctx(L); 
    115115    const char *cert = luaL_checkstring(L, 2); 
    116     return nixio__tls_pstatus(L, SSL_CTX_use_certificate_chain_file(ctx, cert)); 
     116    const char *type = luaL_optstring(L, 3, "chain"); 
     117    int ktype; 
     118 
     119    if (!strcmp(type, "chain")) { 
     120        return nixio__tls_pstatus(L, 
     121                SSL_CTX_use_certificate_chain_file(ctx, cert)); 
     122    } else if (!strcmp(type, "pem")) { 
     123        ktype = SSL_FILETYPE_PEM; 
     124    } else if (!strcmp(type, "asn1")) { 
     125        ktype = SSL_FILETYPE_ASN1; 
     126    } else { 
     127        return luaL_argerror(L, 3, "supported values: chain, pem, asn1"); 
     128    } 
     129 
     130    return nixio__tls_pstatus(L, 
     131            SSL_CTX_use_certificate_file(ctx, cert, ktype)); 
    117132} 
    118133 
  • luci/trunk/libs/px5g/lua/px5g/util.lua

    r4761 r4763  
    3030     
    3131    local outdata = {preamble[type]} 
    32     for i = 1, 64, #b64 + 63 do 
     32    for i = 1, #b64, 64 do 
    3333        outdata[#outdata + 1] = b64:sub(i, i + 63)  
    3434    end 
     
    3838    return table.concat(outdata, "\n") 
    3939end 
     40 
     41function pem2der(data) 
     42    local b64 = data:gsub({["\n"] = "", ["%-%-%-%-%-.-%-%-%-%-%-"] = ""}) 
     43    return nixio.bin.b64decode(b64) 
     44end 
  • luci/trunk/libs/px5g/root/usr/sbin/px5g-genkeys

    r4761 r4763  
    77local fs = require "nixio.fs" 
    88local os = require "os" 
     9nixio.umask(77) 
    910 
    1011if not fs.access(certfile) then 
  • luci/trunk/libs/px5g/src/px5g.c

    r4761 r4763  
    8686    4, "Invalid Time"); 
    8787 
     88    size_t join = 1; 
    8889    lua_pushliteral(L, ""); 
    8990    for (int i = 0; i < (sizeof(xfields) / sizeof(*xfields)); i++) { 
     
    9293        if (lua_isstring(L, -1)) { 
    9394            const char *val = lua_tostring(L, -1); 
    94             luaL_argcheck(L, !strchr(val, '\''), 2, "Invalid Value"); 
    95             lua_pushfstring(L, "%s%s='%s';", 
    96                 lua_tostring(L, -2), xfields[i], val); 
     95            luaL_argcheck(L, !strchr(val, ';'), 2, "Invalid Value"); 
     96            lua_pushfstring(L, "%s=%s;", xfields[i], val); 
    9797            lua_remove(L, -2); 
    98             lua_remove(L, -2); 
     98            join++; 
    9999        } else { 
    100100            lua_pop(L, 1); 
    101101        } 
    102102    } 
     103    lua_concat(L, join); 
    103104 
    104105    x509_raw cert;