pkey=X509_REQ_get_pubkey(x);
#ifndef NO_RSA
- if (pkey->type == EVP_PKEY_RSA)
+ if (pkey != NULL && pkey->type == EVP_PKEY_RSA)
{
BIO_printf(bp,"%12sRSA Public Key: (%d bit)\n","",
BN_num_bits(pkey->pkey.rsa->n));
else
#endif
#ifndef NO_DSA
- if (pkey->type == EVP_PKEY_DSA)
+ if (pkey != NULL && pkey->type == EVP_PKEY_DSA)
{
BIO_printf(bp,"%12sDSA Public Key:\n","");
DSA_print(bp,pkey->pkey.dsa,16);
#endif
BIO_printf(bp,"%12sUnknown Public Key:\n","");
- EVP_PKEY_free(pkey);
+ if (pkey != NULL)
+ EVP_PKEY_free(pkey);
/* may not be */
sprintf(str,"%8sAttributes:\n","");