|
|
@ -79,11 +79,7 @@ namespace openssl { |
|
|
|
} |
|
|
|
} |
|
|
|
virtual ~Engine() { |
|
|
|
virtual ~Engine() { |
|
|
|
OPENSSL_LOG("log"); |
|
|
|
OPENSSL_LOG("log"); |
|
|
|
if (_e) { |
|
|
|
|
|
|
|
OPENSSL_LOG("free the engine"); |
|
|
|
|
|
|
|
OPENSSL_CHECK(ENGINE_free(_e)); |
|
|
|
OPENSSL_CHECK(ENGINE_free(_e)); |
|
|
|
_e = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
virtual const char* id() = 0; |
|
|
|
virtual const char* id() = 0; |
|
|
|
virtual const char* name() = 0; |
|
|
|
virtual const char* name() = 0; |
|
|
@ -149,8 +145,7 @@ namespace openssl { |
|
|
|
_map[e->_e] = e; |
|
|
|
_map[e->_e] = e; |
|
|
|
OPENSSL_CHECK(ENGINE_set_id(e->_e, e->id())); |
|
|
|
OPENSSL_CHECK(ENGINE_set_id(e->_e, e->id())); |
|
|
|
OPENSSL_CHECK(ENGINE_set_name(e->_e, e->name())); |
|
|
|
OPENSSL_CHECK(ENGINE_set_name(e->_e, e->name())); |
|
|
|
OPENSSL_CHECK(ENGINE_set_destroy_function |
|
|
|
OPENSSL_CHECK(ENGINE_set_destroy_function(e->_e, EngineMapper::destroy)); |
|
|
|
(e->_e, EngineMapper::destroy)); |
|
|
|
|
|
|
|
OPENSSL_CHECK(ENGINE_set_init_function(e->_e, EngineMapper::init)); |
|
|
|
OPENSSL_CHECK(ENGINE_set_init_function(e->_e, EngineMapper::init)); |
|
|
|
OPENSSL_CHECK(ENGINE_set_finish_function(e->_e, EngineMapper::finish)); |
|
|
|
OPENSSL_CHECK(ENGINE_set_finish_function(e->_e, EngineMapper::finish)); |
|
|
|
OPENSSL_CHECK(ENGINE_set_ctrl_function(e->_e, EngineMapper::ctrl)); |
|
|
|
OPENSSL_CHECK(ENGINE_set_ctrl_function(e->_e, EngineMapper::ctrl)); |
|
|
@ -172,16 +167,10 @@ namespace openssl { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void remove(Engine *e) { |
|
|
|
static void remove(Engine *e) { |
|
|
|
OPENSSL_LOG("log"); |
|
|
|
|
|
|
|
if (e) { |
|
|
|
|
|
|
|
OPENSSL_LOG("call remove: e->_e = "<<((void*)e->_e)); |
|
|
|
|
|
|
|
OPENSSL_CHECK(ENGINE_remove(e->_e)); |
|
|
|
OPENSSL_CHECK(ENGINE_remove(e->_e)); |
|
|
|
OPENSSL_LOG("call finish"); |
|
|
|
|
|
|
|
OPENSSL_CHECK(ENGINE_finish(e->_e)); |
|
|
|
OPENSSL_CHECK(ENGINE_finish(e->_e)); |
|
|
|
OPENSSL_LOG("erase from map"); |
|
|
|
|
|
|
|
_map.erase(e->_e); |
|
|
|
_map.erase(e->_e); |
|
|
|
delete e; e=0; |
|
|
|
delete e; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
@ -198,7 +187,6 @@ namespace openssl { |
|
|
|
static int finish(ENGINE* e) { |
|
|
|
static int finish(ENGINE* e) { |
|
|
|
OPENSSL_LOG("log"); |
|
|
|
OPENSSL_LOG("log"); |
|
|
|
Map::iterator it(_map.find(e)); |
|
|
|
Map::iterator it(_map.find(e)); |
|
|
|
OPENSSL_LOG("finish: "<<(it!=_map.end()?"true":"false")); |
|
|
|
|
|
|
|
return it!=_map.end()?it->second->finish():0; |
|
|
|
return it!=_map.end()?it->second->finish():0; |
|
|
|
} |
|
|
|
} |
|
|
|
static int ctrl(ENGINE* e, int cmd, long i, void* p, void(*f)()) { |
|
|
|
static int ctrl(ENGINE* e, int cmd, long i, void* p, void(*f)()) { |
|
|
@ -295,30 +283,24 @@ namespace openssl { |
|
|
|
template <class ENGINE=Engine> class RegisterEngine { |
|
|
|
template <class ENGINE=Engine> class RegisterEngine { |
|
|
|
public: |
|
|
|
public: |
|
|
|
RegisterEngine(ENGINE* e = 0): _e(e) { |
|
|
|
RegisterEngine(ENGINE* e = 0): _e(e) { |
|
|
|
OPENSSL_LOG("log"); |
|
|
|
|
|
|
|
if (_e) EngineMapper::add(_e); |
|
|
|
if (_e) EngineMapper::add(_e); |
|
|
|
} |
|
|
|
} |
|
|
|
~RegisterEngine() { |
|
|
|
~RegisterEngine() { |
|
|
|
OPENSSL_LOG("log"); |
|
|
|
|
|
|
|
if (_e) EngineMapper::remove(_e); |
|
|
|
if (_e) EngineMapper::remove(_e); |
|
|
|
} |
|
|
|
} |
|
|
|
RegisterEngine& operator=(ENGINE* e) { |
|
|
|
RegisterEngine& operator=(ENGINE* e) { |
|
|
|
OPENSSL_LOG("log"); |
|
|
|
|
|
|
|
if (_e) EngineMapper::remove(_e); |
|
|
|
if (_e) EngineMapper::remove(_e); |
|
|
|
_e = e; |
|
|
|
_e = e; |
|
|
|
if (_e) EngineMapper::add(_e); |
|
|
|
if (_e) EngineMapper::add(_e); |
|
|
|
return *this; |
|
|
|
return *this; |
|
|
|
} |
|
|
|
} |
|
|
|
operator ENGINE*() { |
|
|
|
operator ENGINE*() { |
|
|
|
OPENSSL_LOG("log"); |
|
|
|
|
|
|
|
return _e; |
|
|
|
return _e; |
|
|
|
} |
|
|
|
} |
|
|
|
ENGINE* operator->() { |
|
|
|
ENGINE* operator->() { |
|
|
|
OPENSSL_LOG("log"); |
|
|
|
|
|
|
|
return _e; |
|
|
|
return _e; |
|
|
|
} |
|
|
|
} |
|
|
|
ENGINE& operator*() { |
|
|
|
ENGINE& operator*() { |
|
|
|
OPENSSL_LOG("log"); |
|
|
|
|
|
|
|
return *_e; |
|
|
|
return *_e; |
|
|
|
} |
|
|
|
} |
|
|
|
private: |
|
|
|
private: |
|
|
|