From 246f5cfe67fda9fa2fed869c2fffb48effcdc6b9 Mon Sep 17 00:00:00 2001 From: gotoyuzo Date: Sun, 18 Sep 2005 22:56:11 +0000 Subject: * ext/openssl/ossl_pkey.h, ossl_pkey_rsa.c, ossl_pkey_dsa.c: an instance variable "private" is added to OpenSSL::PKey class. this ivar is a flag that shows whether there is a private key in the instance. * ext/openssl/ossl_engine.c: (ossl_engine_load_privkey): set private key flag. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/openssl/ossl_engine.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'ext/openssl/ossl_engine.c') diff --git a/ext/openssl/ossl_engine.c b/ext/openssl/ossl_engine.c index 3d943b0098..71586e3620 100644 --- a/ext/openssl/ossl_engine.c +++ b/ext/openssl/ossl_engine.c @@ -217,7 +217,7 @@ ossl_engine_load_privkey(int argc, VALUE *argv, VALUE self) { ENGINE *e; EVP_PKEY *pkey; - VALUE id, data; + VALUE id, data, obj; char *sid, *sdata; rb_scan_args(argc, argv, "02", &id, &data); @@ -230,8 +230,10 @@ ossl_engine_load_privkey(int argc, VALUE *argv, VALUE self) pkey = ENGINE_load_private_key(e, sid, NULL, sdata); #endif if (!pkey) ossl_raise(eEngineError, NULL); + obj = ossl_pkey_new(pkey); + OSSL_PKEY_SET_PRIVATE(obj); - return ossl_pkey_new(pkey); + return obj; } static VALUE @@ -242,8 +244,8 @@ ossl_engine_load_pubkey(int argc, VALUE *argv, VALUE self) VALUE id, data; char *sid, *sdata; - rb_scan_args(argc, argv, "11", &id, &data); - sid = StringValuePtr(id); + rb_scan_args(argc, argv, "02", &id, &data); + sid = NIL_P(id) ? NULL : StringValuePtr(id); sdata = NIL_P(data) ? NULL : StringValuePtr(data); GetEngine(self, e); #if OPENSSL_VERSION_NUMBER < 0x00907000L -- cgit v1.2.3