【问题标题】:OpenSSL dereferencing pointer to incomplete typeOpenSSL 取消引用指向不完整类型的指针
【发布时间】:2013-06-01 23:34:13
【问题描述】:

我正在使用 OpenSSL 库。我正在尝试访问 struct engine_st 的 rsa_meth 属性。做的代码如下:

ctx->client_cert_engine->rsa_meth

其中 ctx 是 SSL_CTX * 类型。

我试图包含所有必要的头文件,但它仍然给了我:

dereferencing pointer to incomplete type.

不过,如果我删除 rsa_meth 就可以了。

【问题讨论】:

    标签: c ssl struct openssl


    【解决方案1】:

    engine_st(即 client_cert_engine 是什么)是一个内部结构定义(它在 crypto/engine/eng_int.h 中)并且未在公共标头中公开。这(可能)是为了防止在更改结构时出现二进制兼容性问题。不要尝试取消引用,而是使用 engine.h 标头中定义的 getter:

     const char *ENGINE_get_id(const ENGINE *e);
     const char *ENGINE_get_name(const ENGINE *e);
     const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e);
     const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e);
     const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e);
     const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e);
     const DH_METHOD *ENGINE_get_DH(const ENGINE *e);
     const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e);
     const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e);
    

    【讨论】:

      【解决方案2】:

      这意味着没有定义 RSA_METH 结构。您需要在 openssl/rsa.h 中包含其定义

      请包含 openssl/rsa.h 或

      添加

      #include <openssl/rsa.h>
      

      此代码之前的代码。

      【讨论】:

      • 还有一件事,我发现问题不仅仅在于 RSA_METH,我无法从 client_cert_engine 结构中访问任何元素。所以我假设代码无法找到 engine_st 结构的定义。
      【解决方案3】:

      您正在取消引用 ctx->client_cert_engine,它是一个 ENGINE *(指向 struct engine_st 的指针)。

      尝试包含&lt;openssl/engine.h&gt;

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-03-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多