1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
From 2fb6331a5304927fcfe915d5d42535d3d500f540 Mon Sep 17 00:00:00 2001
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Date: Sun, 2 Sep 2018 13:18:48 +0300
Subject: [PATCH 02/10] pkey.toPEM: accept table arguments
---
src/openssl.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/openssl.c b/src/openssl.c
index acb8289..1905693 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -4681,8 +4681,17 @@ static int pk_toPEM(lua_State *L) {
// "params", "Parameters",
NULL,
};
+ int type;
- switch (auxL_checkoption(L, i, NULL, types, 1)) {
+ if (!lua_istable(L, i))
+ lua_pushvalue(L, i);
+ else if (!getfield(L, i, "type"))
+ lua_pushliteral(L, "public");
+
+ type = auxL_checkoption(L, -1, NULL, types, 1);
+ lua_pop(L, 1);
+
+ switch (type) {
case 0: case 1: /* public, PublicKey */
if (!PEM_write_bio_PUBKEY(bio, key))
return auxL_error(L, auxL_EOPENSSL, "pkey:__tostring");
--
2.24.1
|