nixio: Add support for DER keyfiles
This commit is contained in:
parent
c07ab17d59
commit
0d20041419
2 changed files with 12 additions and 1 deletions
|
@ -44,6 +44,7 @@
|
||||||
#define SSL_OP_NO_SSLv3 0x02000000L
|
#define SSL_OP_NO_SSLv3 0x02000000L
|
||||||
#define SSL_OP_NO_SSLv2 0x01000000L
|
#define SSL_OP_NO_SSLv2 0x01000000L
|
||||||
#define SSL_FILETYPE_PEM 1
|
#define SSL_FILETYPE_PEM 1
|
||||||
|
#define SSL_FILETYPE_ASN1 2
|
||||||
#define SSL_VERIFY_NONE 0x00
|
#define SSL_VERIFY_NONE 0x00
|
||||||
#define SSL_VERIFY_PEER 0x01
|
#define SSL_VERIFY_PEER 0x01
|
||||||
#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02
|
#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02
|
||||||
|
|
|
@ -119,7 +119,17 @@ static int nixio_tls_ctx_set_cert(lua_State *L) {
|
||||||
static int nixio_tls_ctx_set_key(lua_State *L) {
|
static int nixio_tls_ctx_set_key(lua_State *L) {
|
||||||
SSL_CTX *ctx = nixio__checktlsctx(L);
|
SSL_CTX *ctx = nixio__checktlsctx(L);
|
||||||
const char *cert = luaL_checkstring(L, 2);
|
const char *cert = luaL_checkstring(L, 2);
|
||||||
const int ktype = SSL_FILETYPE_PEM;
|
const char *type = luaL_optstring(L, 3, "pem");
|
||||||
|
int ktype;
|
||||||
|
|
||||||
|
if (!strcmp(type, "pem")) {
|
||||||
|
ktype = SSL_FILETYPE_PEM;
|
||||||
|
} else if (!strcmp(type, "asn1")) {
|
||||||
|
ktype = SSL_FILETYPE_ASN1;
|
||||||
|
} else {
|
||||||
|
return luaL_argerror(L, 3, "supported values: pem, asn1");
|
||||||
|
}
|
||||||
|
|
||||||
return nixio__tls_pstatus(L, SSL_CTX_use_PrivateKey_file(ctx, cert, ktype));
|
return nixio__tls_pstatus(L, SSL_CTX_use_PrivateKey_file(ctx, cert, ktype));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue