X509_STORE_CTX_init(&ctx,s->ctx->cert_store,x,sk);
if(!X509_STORE_CTX_init(&ctx,s->ctx->cert_store,x,sk)) { SSLerr(SSL_F_SSL_VERIFY_CERT_CHAIN,ERR_R_X509_LIB); return(0); }
int ssl_verify_cert_chain(SSL *s,STACK_OF(X509) *sk)	{	X509 *x;	int i;	X509_STORE_CTX ctx;	if ((sk == NULL) || (sk_X509_num(sk) == 0))		return(0);	x=sk_X509_value(sk,0);	X509_STORE_CTX_init(&ctx,s->ctx->cert_store,x,sk);	if (SSL_get_verify_depth(s) >= 0)		X509_STORE_CTX_set_depth(&ctx, SSL_get_verify_depth(s));	X509_STORE_CTX_set_ex_data(&ctx,SSL_get_ex_data_X509_STORE_CTX_idx(),s);	/* We need to set the verify purpose. The purpose can be determined by	 * the context: if its a server it will verify SSL client certificates	 * or vice versa.	 */	if (s->server)		i = X509_PURPOSE_SSL_CLIENT;	else		i = X509_PURPOSE_SSL_SERVER;	X509_STORE_CTX_purpose_inherit(&ctx, i, s->purpose, s->trust);	if (s->verify_callback)		X509_STORE_CTX_set_verify_cb(&ctx, s->verify_callback);	if (s->ctx->app_verify_callback != NULL)		i=s->ctx->app_verify_callback(&ctx); /* should pass app_verify_arg */	else		{#ifndef OPENSSL_NO_X509_VERIFY		i=X509_verify_cert(&ctx);#else		i=0;		ctx.error=X509_V_ERR_APPLICATION_VERIFICATION;		SSLerr(SSL_F_SSL_VERIFY_CERT_CHAIN,SSL_R_NO_VERIFY_CALLBACK);#endif		}	s->verify_result=ctx.error;	X509_STORE_CTX_cleanup(&ctx);	return(i);	}