Multiprocessing using PyCurl zymkey_ssl engine


I have a Zymkey 4 in a Raspberry Pi signing requests in some processes using pycurl. However when i have 3 or more processes at the same time, i receive the error below:

(66, “Failed to initialise SSL Engine ‘zymkey_ssl’:\nerror:00000000:lib(0):func(0):reason(0)”)

Could you help me?

This is the code that I’m using to test it:

while True:
buffer = BytesIO()

    c = pycurl.Curl()
    c.setopt(c.SSLENGINE, "zymkey_ssl")
    c.setopt(c.SSLENGINE_DEFAULT, 1)
    c.setopt(c.SSLVERSION, c.SSLVERSION_TLSv1_2)

    # Settings certificates for HTTPS connection
    c.setopt(c.SSLCERTTYPE, "PEM")

    # setting endpoint and HTTPS type, here it is a POST
    c.setopt(c.URL, URL)

    c.setopt(pycurl.CUSTOMREQUEST, "GET")

    c.setopt(c.WRITEFUNCTION, buffer.write)
    c.setopt(c.HTTPHEADER, ['Content-Type: application/json'])
    c.setopt(c.TIMEOUT, 60)

    # Telling Curl to do client and host authentication
    c.setopt(c.SSL_VERIFYPEER, 1)
    c.setopt(c.SSL_VERIFYHOST, 2)

    # Turn off Verbose output and set key as placeholder, not actually a real file.
    c.setopt(c.VERBOSE, 0)
    c.setopt(c.SSLKEYTYPE, "ENG")
    c.setopt(c.SSLKEY, TPM_DUMMY_KEY_PATH)
    response = buffer.getvalue().decode("utf-8")
except Exception as e:
    print("ERROR -> " + str(e))


@DiegoFdez - Can you post your entire program as it runs? I’ll make sure I see the same thing here and hopefully I can help you out.


The code that i have posted in the last message is my entire program. If you run that code in multiple processes at the same time, Zimkey ends up with the following error:

(66, “Failed to initialise SSL Engine ‘zymkey_ssl’:\nerror:00000000:lib(0):func(0):reason(0)”)

Use your own auto signed certificate (CERTIFICATE_PEM_PATH), your own CA (CERTIFICATE_CA_PATH), use for example, or whatever you want (URL), and as TPM_DUMMY_KEY_PATH whatever file end in .key