From cd859abad9318b2ffb29d9a8caf3342ca01081ec Mon Sep 17 00:00:00 2001 From: William Ahern Date: Thu, 17 Dec 2015 16:39:43 +0800 Subject: forgot to call BIO_reset after pushing the private key PEM text, which in the multiple argument form caused the next PEM text to be appended. closes issue #34 --- src/openssl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/openssl.c b/src/openssl.c index 8d1435a..e91e270 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -2420,8 +2420,8 @@ static int pk_toPEM(lua_State *L) { len = BIO_get_mem_data(bio, &pem); lua_pushlstring(L, pem, len); - BIO_reset(bio); + break; case 2: case 3: /* private, PrivateKey */ if (!PEM_write_bio_PrivateKey(bio, key, 0, 0, 0, 0, 0)) @@ -2429,6 +2429,7 @@ static int pk_toPEM(lua_State *L) { len = BIO_get_mem_data(bio, &pem); lua_pushlstring(L, pem, len); + BIO_reset(bio); break; #if 0 -- cgit v1.2.3-55-g6feb