static int crl_akid_check(X509_STORE_CTX *ctx, X509_CRL *crl, X509 **pissuer)
	{
	X509 *crl_issuer;
	int cidx = ctx->error_depth;
	if (!crl->akid)
		return 1;
	if (cidx != sk_X509_num(ctx->chain) - 1)
		cidx++;
	crl_issuer = sk_X509_value(ctx->chain, cidx);
	if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK)
		return 1;
	/* If crl_issuer is self issued we may get a match further along the
	 * chain.
	 */
	if (crl_issuer->ex_flags & EXFLAG_SI)
		{
		for (cidx++; cidx < sk_X509_num(ctx->chain); cidx++)
			{
			crl_issuer = sk_X509_value(ctx->chain, cidx);
			if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK)
				{
				*pissuer = crl_issuer;
				return 1;
				}
			if (!(crl_issuer->ex_flags & EXFLAG_SI))
				break;
			}
		}
		
	return 0;
	}