gpt4 book ai didi

ssl - ASN.1 结构迭代器只是被声明但没有实现

转载 作者:太空宇宙 更新时间:2023-11-03 14:38:08 24 4
gpt4 key购买 nike

这是我的示例代码:

#include <openssl/asn1.h>
#include <openssl/asn1t.h>
#include <openssl/rsa.h>
#include <openssl/x509.h>

typedef struct key_st {
X509_ALGOR *algorithm_id;
RSA *key_material;
} KEY;

DECLARE_ASN1_FUNCTIONS(KEY)

IMPLEMENT_ASN1_FUNCTIONS(KEY)

int main()
{
return 0;
}

编译时报如下错误:

$ gcc -o ssltest ssltest.c -lssl -lcrypto
/tmp/cch0HA77.o: In function `d2i_KEY':
ssltest.c:(.text+0x21): undefined reference to `KEY_it'
/tmp/cch0HA77.o: In function `i2d_KEY':
ssltest.c:(.text+0x48): undefined reference to `KEY_it'
/tmp/cch0HA77.o: In function `KEY_new':
ssltest.c:(.text+0x5e): undefined reference to `KEY_it'
/tmp/cch0HA77.o: In function `KEY_free':
ssltest.c:(.text+0x7a): undefined reference to `KEY_it'
collect2: error: ld returned 1 exit status

查看宏扩展代码后,发现KEY_it声明为:

extern const ASN1_ITEM KEY_it;

因此链接器报告 undefined reference 。我该如何解决?非常感谢!

最佳答案

在我添加 KEY 的序列定义后修复:

ASN1_SEQUENCE(KEY) = { 
ASN1_SIMPLE(KEY, algorithm_id, X509_ALGOR),
ASN1_SIMPLE(KEY, key_material, RSAPublicKey)
} ASN1_SEQUENCE_END(KEY)

关于ssl - ASN.1 结构迭代器只是被声明但没有实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45912852/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com