我在编译 openssl 函数以使用 G++ 编译器从公共证书获取到期日期时遇到问题。
错误是,
error: expected unqualified-id before ‘not’ token
error: expected primary-expression before ‘)’ token
编译过程,
g++ main.c -o test -I /usr/include/openssl/ -lcrypto -lssl
包含所有头文件。
下面我编译的代码,
main ()
{
X509 *x;
int n=0;
unsigned char *not; //expected unqualified-id before ‘not’ token ,expected initializer before ‘not’ token
BIO *out;
FILE *fp=fopen("/home/public.cer", "r");
x = X509_new();
x = PEM_read_X509(fp,NULL,NULL,NULL);
fclose(fp);
out = BIO_new(BIO_s_mem());
ASN1_TIME_print(out, X509_get_notAfter(x));//expected primary-expression before ‘)’ token
n = BIO_get_mem_data(out, ¬);
expiryStr = (char *) malloc (n+1);
expiryStr[n] = '\0';
memcpy(expiryStr, not, n);//expected primary-expression before ‘)’ token
printf("Expiry Date====================%s\n",expiryStr);
BIO_free(out);
X509_free(x);
}
请帮我解决这个错误。