Hi
I am trying to read a public key from a certificate file in PEM format.
My code looks as follows.
I constanty get null as a result from the call to PEM_read_RSAPublicKey
#include <openssl/ssl.h>
#include <openssl/x509.h>
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <openssl/err.h>
#include <openssl/bio.h>
#include <string.h>
#include "main.h"
#define HOME "/home/hetregenza/projects/ssl_cert/"
//#define HOME "./"
#define CLIENTCERTF HOME "clientcert.pem"
#define CLIENTKEYF HOME "clientkey.pem"
#define SERVERCERTF HOME "servercert.pem"
#define SERVERKEYF HOME "serverkey.pem"
#define CASERVCERTF HOME "cacert.pem"
int main(int argc, char ** argv)
{
void * pUser;
char szUser[2000];
EVP_PKEY * pEVP_PKEY = 0;
EVP_PKEY ** ppEVP_PKEY = 0;
BIO_METHOD * pBIO_METHOD;
BIO * pBIO = 0;
RSA * pRSA = 0;
RSA ** ppRSA = 0;
pBIO_METHOD = BIO_s_file();
memset (&szUser, 0, sizeof(szUser));
pBIO = BIO_new_file(CLIENTCERTF, "r");
pRSA = PEM_read_bio_RSAPublicKey(pBIO, ppRSA, PasswdCallback, (void *)szUser); // get null back here.
BIO_free(pBIO);
return 0;
}
The code does not even get to the call back function.
Any assistance appreciated
Hylton
smime.p7s
Description: application/pkcs7-signature