Nothing like forgetting to add Algorithms which was the issue

ERR_load_BIO_strings();
ERR_load_crypto_strings();
OpenSSL_add_all_algorithms();
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();

basically get the public key

 testrsa = RSA_new();
  FILE *fp = fopen("x509public.pem", "r"); 
  if(PEM_read_RSAPublicKey(fp, &testrsa, NULL, NULL) == NULL) {
      printf("\n%s\n", "Error Reading public key x509public.pem");
      return; 
   }
  printf("TEST KEY OKAY \n");

Set the EVP up.

EVP_PKEY *pk;  

  if ((pk=EVP_PKEY_new()) == NULL){
      fprintf(stderr,"err 1\n");
      return;
    }
  printf("here now \n");
 EVP_PKEY * pubkey=EVP_PKEY_new();
 int rc=EVP_PKEY_set1_RSA(pubkey, testrsa);


Load the x509


 x=NULL; 
  x=  PEM_read_X509(fp,&x, NULL, NULL); 
  if (x==NULL){
     fprintf(stderr,"null x509\n");
     return;
  }
  fclose(fp);


and verify it

 rc= X509_verify(x,pubkey);


returns a 1 value now.  done.





--
View this message in context: 
http://openssl.6102.n7.nabble.com/verify-self-signed-x-509-tp45026p45034.html
Sent from the OpenSSL - User mailing list archive at Nabble.com.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to