Let's assume that the public key is in a pem encoded X509 file called x.pem
// Access the file FILE *fptr=NULL; fptr = fopen( "x.pem", "r" ); // Read in the certificate to an X509 structure X509 *cert_A=NULL; cert_A = PEM_read_X509_AUX( fptr, NULL, NULL, NULL ); // Extract the public key from the cert structure EVP_PKEY *evp_A=NULL; evp_A = X509_get_pubkey( cert_A ); Of course you will want to add appropriate error checking around this and generalize it. Bill ________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ben Hoover Sent: April 23, 2008 3:17 PM To: openssl-users@openssl.org Subject: Extracting Public Key from a File Hello, Is there a way to extract a public key from a PEM encoded file and turn it into an EVP_PKEY struct? Also is there a way to directly extract the RSA data directly from the file containing the public key and put it into an RSA struct? Thank you, Ben ________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. <http://us.rd.yahoo.com/evt=51733/*http:/mobile.yahoo.com/;_ylt=Ahu06i62 sR8HDtDypao8Wcj9tAcJ%20>