我们有一个项目需要在 iOS 设备上运行一个 openssl 引擎。我们已经为测试引擎编译了 .so 文件,它可以在命令行中正常工作。但是当我们把它放到iOS项目中并尝试加载引擎时,加载步骤总是报错。
NSString *enginePath = [[NSBundle mainBundle] pathForResource:@"silly-engine" ofType:@"so"];
char* engine_id = "silly-engine";
char* engine_path = (char *)[enginePath UTF8String];
ENGINE_load_dynamic();
ENGINE *dyn = ENGINE_by_id("dynamic");
if (!ENGINE_ctrl_cmd_string(dyn, "SO_PATH", engine_path, 0))
{
NSLog(@"SO_PATH failed");
}
if (!ENGINE_ctrl_cmd_string(dyn, "DIR_ADD", engine_path, 0))
{
NSLog(@"DIR_ADD failed");
}
if (!ENGINE_ctrl_cmd_string(dyn, "ID", engine_id, 0))
{
NSLog(@"ID failed");
}
if (!ENGINE_ctrl_cmd(dyn, "LIST_ADD", 1, NULL, NULL, 0))
{
NSLog(@"LIST_ADD failed");
}
if (!ENGINE_ctrl_cmd_string(dyn, "LOAD", NULL, 0))
{
NSLog(@"LOAD failed");
}
ENGINE *myEngine = ENGINE_by_id(engine_id);
myEngine
将远去NULL
。我怀疑 iOS 不允许这样的动态库。有没有人有经验如何使 OpenSSL 引擎在 iOS 上工作?