error: dereferencing pointer to incomplete type ‘RSA {aka struct rsa_st}’

error: dereferencing pointer to incomplete type ‘RSA {aka struct rsa_st}’

我有以下代码:

#include <openssl/bn.h>
#include <openssl/rsa.h>

...
RSA *pubkey = RSA_new();
BIGNUM *modulus = BN_new();
...
pubkey->n = BN_new();
BN_copy(pubkey->n, modulus);

像这样遵守:

gcc rsatest.c -o rsatest -lcrypto

我收到以下错误:

rsatest.c: In function ‘main’:
rsatest.c:57:8: error: dereferencing pointer to incomplete type ‘RSA {aka struct rsa_st}’
  pubkey->n = BN_new();
        ^~

这里有什么问题? 谢谢

RSA_set0_key(pubkey, modulus, exponent, NULL);

而不是

pubkey->n = BN_new();
BN_copy(pubkey->n, modulus);
pubkey->e = BN_new();
BN_copy(pubkey->e, exponent);

解决问题。