From 3c706b4645926ab231a0dd0a7fcfb6e766103a9f Mon Sep 17 00:00:00 2001 From: toddouska Date: Mon, 23 Dec 2013 12:15:55 -0800 Subject: [PATCH] only set up tmp ctx if using password --- src/ssl.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index ba0021f97..2f54e0ebd 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -1091,11 +1091,13 @@ int CyaSSL_KeyPemToDer(const unsigned char* pem, int pemSz, unsigned char* buff, der.buffer = NULL; #ifdef OPENSSL_EXTRA - info.ctx = CyaSSL_CTX_new(CyaSSLv23_client_method()); - if (info.ctx == NULL) - return MEMORY_E; - CyaSSL_CTX_set_default_passwd_cb(info.ctx, OurPasswordCb); - CyaSSL_CTX_set_default_passwd_cb_userdata(info.ctx, (void*)pass); + if (pass) { + info.ctx = CyaSSL_CTX_new(CyaSSLv23_client_method()); + if (info.ctx == NULL) + return MEMORY_E; + CyaSSL_CTX_set_default_passwd_cb(info.ctx, OurPasswordCb); + CyaSSL_CTX_set_default_passwd_cb_userdata(info.ctx, (void*)pass); + } #endif ret = PemToDer(pem, pemSz, PRIVATEKEY_TYPE, &der, NULL, &info, &eccKey);