Sorry, I asked to early, There is nothing wrong with the code. The file is not a public key file (or the format isd wrong) How do I extract a public key file from a certificate?
Hylton
-----Original Message-----
From: Hylton Tregenza
Sent: 16 November 2001 12:24
To: [EMAIL PROTECTED]
Subject: PEM_read_RSAPublicKey

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

Attachment: smime.p7s
Description: application/pkcs7-signature

Reply via email to