2012-10-02 86 views
0

編譯openssl函數以使用G ++編譯器從公共證書獲取到期日期時遇到問題。G ++編譯erro for openssl API

錯誤的是,

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, &not); 
     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);   
} 

請幫我解決這個錯誤。

回答