Here is my code snippet:
 
   int fd;
   BIO *bio;
   fd = open(file, "r" );
   bio = BIO_new(BIO_s_fd() );
   BIO_set_fd(bio,fd,  BIO_NOCLOSE);
 
   X509 *x=null;
   x= PEM_read_bio_X509(data, NULL,ctx->default_password_callback, ctx->default_password_callback_userdata);
 
 
PEM_read_bio_X509 call fails and it returns null. 
 
In the above code, if i change the fd BIO  to FILE*  BIO as mentioned below, everything works.
  FILE *fp = fopen(file, "r" );
  bio= BIO_new(BIO_s_file() );
  BIO_set_fp(data, fp, BIO_NOCLOSE);
 
Am i missing anything? I am trying to avoid STDIO functions and hence i am operating on fds.
 
Thanks for your help.
 
Vijay
 
 

Reply via email to