diff options
author | Martin Willi <martin@revosec.ch> | 2011-04-21 10:48:16 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2011-04-21 10:48:16 +0200 |
commit | 3e2419ebe32de72d824864eb2e0e677a7c197af1 (patch) | |
tree | 2ee06332c69629a83bdca2de75daa057174535ef /src/libstrongswan/plugins/openssl | |
parent | 17ce69b47a1efd6234960cf7d1f50712aee61db5 (diff) | |
download | strongswan-3e2419ebe32de72d824864eb2e0e677a7c197af1.tar.bz2 strongswan-3e2419ebe32de72d824864eb2e0e677a7c197af1.tar.xz |
Use thread save settings alloc_str function where appropriate
Diffstat (limited to 'src/libstrongswan/plugins/openssl')
-rw-r--r-- | src/libstrongswan/plugins/openssl/openssl_rsa_private_key.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/libstrongswan/plugins/openssl/openssl_rsa_private_key.c b/src/libstrongswan/plugins/openssl/openssl_rsa_private_key.c index 0b607c386..39c28d3cd 100644 --- a/src/libstrongswan/plugins/openssl/openssl_rsa_private_key.c +++ b/src/libstrongswan/plugins/openssl/openssl_rsa_private_key.c @@ -550,36 +550,34 @@ openssl_rsa_private_key_t *openssl_rsa_private_key_connect(key_type_t type, if (!engine_id) { - engine_id = lib->settings->get_str(lib->settings, + engine_id = lib->settings->alloc_str(lib->settings, "libstrongswan.plugins.openssl.engine_id", "pkcs11"); } engine = ENGINE_by_id(engine_id); if (!engine) { DBG2(DBG_LIB, "engine '%s' is not available", engine_id); - return NULL; + goto engine_failed; } if (!ENGINE_init(engine)) { DBG1(DBG_LIB, "failed to initialize engine '%s'", engine_id); - ENGINE_free(engine); - return NULL; + goto engine_failed; } if (!login(engine, keyid)) { DBG1(DBG_LIB, "login to engine '%s' failed", engine_id); - ENGINE_free(engine); - return NULL; + goto engine_failed; } key = ENGINE_load_private_key(engine, keyname, NULL, NULL); if (!key) { DBG1(DBG_LIB, "failed to load private key with ID '%s' from " "engine '%s'", keyname, engine_id); - ENGINE_free(engine); - return NULL; + goto engine_failed; } ENGINE_free(engine); + free(engine_id); this = create_empty(); this->rsa = EVP_PKEY_get1_RSA(key); @@ -594,5 +592,12 @@ openssl_rsa_private_key_t *openssl_rsa_private_key_connect(key_type_t type, #else /* OPENSSL_NO_ENGINE */ return NULL; #endif /* OPENSSL_NO_ENGINE */ +engine_failed: + if (engine) + { + ENGINE_free(engine); + } + free(engine_id); + return NULL; } |