Need help using M2Crypto.Engine to access USB Token

前端 未结 6 681
自闭症患者
自闭症患者 2021-01-07 00:09

I am using M2Crypto-0.20.2. I want to use engine_pkcs11 from the OpenSC project and the Aladdin PKI client for token based authentication making xmlrpc calls over ssl.

6条回答
  •  北荒
    北荒 (楼主)
    2021-01-07 00:56

    Found !!!!

    Yes, exactly the way where I came from.

    So, actually the ENGINE_init() is not implemented in M2Crypto.Engine. So, only one solution: patching!!! (very small...) so I've created a new Engine method (in Engine.py)

    def engine_initz(self):
            """Return engine name"""
            return m2.engine_initz(self._ptr)
    

    Why engine_initz ? because engine_init is already define in SWIG/_engine.i,:

    void engine_init(PyObject *engine_err) {
        Py_INCREF(engine_err);
        _engine_err = engine_err;
    }
    

    I don't really know what is done, so I've prefered creating a new one... So I've just added the following to SWIG/_engine.i:

    %rename(engine_initz) ENGINE_init;
    extern int ENGINE_init(ENGINE *);
    

    And recompile the __m2crypto.so, now just add a "pkcs11.engine_initz()" before launching the private key, and it works.....

提交回复
热议问题