> From: owner-openssl-us...@openssl.org On Behalf Of krishnamurthy santhanam > Sent: Tuesday, 31 August, 2010 13:33
> #include<stdio.h> > writekey(RSA *key2) You're obviously using a C89 (or earlier) compiler or mode. Snipped most non-I/O steps: > { > EVP_PKEY *pkey; > FILE *fp; > //BIO *file; > OpenSSL_add_all_ciphers(); > OpenSSL_add_all_algorithms(); Aside: add_all_algorithms *includes* add_all_ciphers > if(!(fp = fopen("private1.pem", "w"))) { > if(!PEM_write_PrivateKey(fp, pkey,NULL,NULL,0,NULL,NULL)){ > close(fp); > if(!(fp = fopen("public1.pem", "w"))) { > if(!PEM_write_PUBKEY(fp, pkey)){ > close(fp); close() is not the correct routine to close a stdio FILE*. It doesn't even take the correct type of argument, but your compiler wasn't required to warn you because you didn't include its header (e.g. unistd.h) and in C<=89 undeclared functions default to int(/*unspecified*/). Since you didn't close the files, no data actually got written to them, so there was nothing there for the PEM_read's to read. Use fclose. And see if you can use a C99 compiler, or at least a C89 compiler with better warnings (like gcc -Wimplicit). ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org