Hi,

I generated a x509 certificate. When I try to read the private key with
PEM_read_PrivateKey I always get NULL as return value and when calling
perror I get an Illegal seek.

Here is my code:

        FILE *pemKeyFile;
        EVP_PKEY *privKey;

        pemKeyFile = fopen ("/home/user/testkey.pem", "r");
        if (pemKeyFile == NULL) {
                perror ("open key file");
                return 7;
        }
        // reading private key in PEM format
        privKey = PEM_read_PrivateKey (pemKeyFile,
                NULL,
                NULL,
                NULL );
        if (privKey==NULL){
                perror("read");
                return 6;
        }
        if (EVP_PKEY_type(privKey->type)==EVP_PKEY_RSA){
                printf ("Key type is: %d this means RSA\n",privKey->type);
        }
        else {
                printf ("NO RSA :(\n");
        }

Can anyone tell me why this does not work ?

My openssl Version is a debian package named: 0.98c-4etch3.

Thanks in ad.

Ciao
   Matthias

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to