Reputation: 585
I have encountered problem while compiling the openssl function to get the expiry date from public certificate using G++ compiler.
The error's are,
error: expected unqualified-id before ‘not’ token
error: expected primary-expression before ‘)’ token
Compilation procedure,
g++ main.c -o test -I /usr/include/openssl/ -lcrypto -lssl
All the header files are included.
Code below I have compiled,
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);
}
Please help me resolving this error.
Upvotes: 0
Views: 314
Reputation: 1168
"not" is a keyword in C++: http://en.cppreference.com/w/cpp/keyword. You'll have to rename the variable.
Upvotes: 3