ENGINE_init fails on TPM engine

Yichun Ding yicding at gmail.com
Wed Oct 16 06:45:18 UTC 2019

openssl version: *1.0.1e*

During reboot, the following code is used to set up the tpm engine:

    e = ENGINE_by_id("tpm");
    if(!e) {
        /* the engine isn't available */
        ERR("ENGINE_by_id failed.");
        return CU_ERROR;

    if (!ENGINE_init(e)) {
        int err_num = ERR_get_error();
        char buf[128] = {0};

*        ERR("ENGINE_init failed.");*        printf("ENGINE_init error:
%s\n", ERR_error_string(err_num, buf));
        return CU_ERROR;

What happens is that ENGINE_init(e) fails sometimes (not always) with the
following error:

*ENGINE_init error: error:00000000:lib(0):func(0):reason(0)*

There is no race condition in this case as far as I can tell.

Is this a bug in this version of openSSL?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mta.openssl.org/pipermail/openssl-users/attachments/20191015/42a782f3/attachment.html>

More information about the openssl-users mailing list