无法在硬件模式下创建 SGX 飞地 - "invalid launch token" 即使文档将无效的启动令牌指定为第一个

Unable to create SGX enclave in hardware mode - "invalid launch token" even though documentation specifies an invalid launch token as the first one

Intel 的文档说 here 如果没有先前的启动令牌,则应使用全为零的 "invalid" 令牌。这在模拟模式下完美运行,但在硬件模式下它 returns SGX_ERROR_INVALID_LAUNCH_TOKEN,即使这正是它所要求的。

    // Initialize an "invalid" first token, as the documentation specifies (all zeros)
    sgx_launch_token_t token = {0};

    // Create enclave
    sgx_enclave_id_t id;
    int updated = 0;
    const auto status = sgx_create_enclave("enclave.signed.so", SGX_DEBUG_FLAG, &token, &updated, &id, NULL);

    if (status != SGX_SUCCESS) {
        throw "Failed to initialize enclave. (" + get_error_message(status) + ")";
    }

代码returns状态=SGX_ERROR_INVALID_LAUNCH_TOKEN

Failed to initialize enclave. (The launch token is not correct.)

我在构建过程中可能遗漏了什么吗?

问题是由于我的应用程序使用 /usr/lib 中的 libsgx_urts.so 和我的 SGX SDK 安装路径中的 libsgx_uae_service.so(在我的例子中是 /opt/intel/sgxsdk/lib64。)

我将链接更改为以下内容:

Simulation mode: libsgx_urts.so => /opt/intel/sgxsdk/lib64/libsgx_urts.so libsgx_uae_service.so => /opt/intel/sgxsdk/lib64/libsgx_uae_service.so

Hardware mode: libsgx_urts.so => /usr/lib/libsgx_urts.so libsgx_uae_service.so => /usr/lib/libsgx_uae_service.so `