-
Notifications
You must be signed in to change notification settings - Fork 3
Description
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