Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get 'dynamic' engine module to load any engines #1

Open
jmccanta opened this issue Jul 18, 2022 · 0 comments
Open

Unable to get 'dynamic' engine module to load any engines #1

jmccanta opened this issue Jul 18, 2022 · 0 comments

Comments

@jmccanta
Copy link

Given the code below, and this patch, so I could pass None to engine_init, I could not get the 'dynamic' engine to load any dynamic engines. I have tried several. The commands work when using openssl command line and in C programs. I have verified with ltrace that the call to ENGINE_ctrl_cmd_string is passing a NULL where None is. And, now I am stumped.
From the openssl command line, it works.

$ openssl engine dynamic -v -pre SO_PATH:/usr/lib/x86_64-linux-gnu/engines-1.1/pkcs11.so -pre LIST_ADD:1 -pre LOAD
(dynamic) Dynamic engine loading support
[Success]: SO_PATH:/usr/lib/x86_64-linux-gnu/engines-1.1/pkcs11.so
[Success]: LIST_ADD:1
[Success]: LOAD
Loaded: (pkcs11) pkcs11 engine
SO_PATH, MODULE_PATH, PIN, VERBOSE, QUIET, INIT_ARGS, FORCE_LOGIN

The output of the equivalent using cryptography_engine:

Traceback (most recent call last):
File "pyssl.py", line 15, in
e = engine.engine_init('dynamic', [
File "/home/mccanta-admin/.local/lib/python3.8/site-packages/cryptography_engine/engine.py", line 157, in engine_init
raise ValueError(f"ENGINE failed at command {k}")
ValueError: ENGINE failed at command ('LOAD', None)

#!/usr/bin/python3
import sys
import typing
import cryptography
import cryptography_engine.engine as engine
e = engine.engine_init('dynamic', [
                           ('SO_PATH','/usr/lib/x86_64-linux-gnu/engines-1.1/pkcs11.so'),
                           ("LIST_ADD", "1"),
                           ("LOAD", None)  ])
Patch:
-            e, k[0].encode("ascii"), k[1].encode("ascii"), 0
+            e,
+            k[0].encode("ascii"),
+            _ffi.NULL if k[1] is None else k[1].encode("ascii"),
+            0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant