[openssl-users] SSL alert number 48

Viktor Dukhovni openssl-users at dukhovni.org
Wed Nov 29 13:54:10 UTC 2017


On Wed, Nov 29, 2017 at 09:56:35AM +0100, Jan Just Keijser wrote:

> Try adding this to the verify_callback
> 
> 
> static int verify_callback(int ok, X509_STORE_CTX *ctx)
> {
>     X509           *cert = NULL;
>     char           *cert_DN = NULL;
> 
>     printf("ok = %d\n", ok);
>     cert    = X509_STORE_CTX_get_current_cert(ctx);
>     cert_DN = X509_NAME_oneline( X509_get_subject_name( cert ), NULL, 0 );
>     printf( "cert DN: %s\n", cert_DN);
> 
> }

You've left out the final "return ok;", and there's a new memory
leak.  Closer would be:

     static int verify_callback(int ok, X509_STORE_CTX *ctx)
     {
         X509           *cert = NULL;
         char           *cert_DN = NULL;
     
         printf("ok = %d\n", ok);
         cert    = X509_STORE_CTX_get_current_cert(ctx);
         cert_DN = X509_NAME_oneline( X509_get_subject_name( cert ), NULL, 0 );
         printf( "cert DN: %s\n", cert_DN);

	 OPENSSL_free(cert_DN);
	 return ok;
     }

-- 
	Viktor.


More information about the openssl-users mailing list