anchor.diff:  	{_, true = SelfSigned} ->
   	    do_certificate_chain(CertDbHandle, CertsDbRef, Chain, ignore, ignore, SelfSigned, ListDb);
   	{{error, issuer_not_found}, SelfSigned} ->
  -	    case find_issuer(OtpCert, BinCert, CertDbHandle, CertsDbRef, ListDb) of
  +	    case find_issuer(Cert, CertDbHandle, CertsDbRef, ListDb) of
   		{ok, {SerialNr, Issuer}} ->
   		    do_certificate_chain(CertDbHandle, CertsDbRef, Chain,
   					 SerialNr, Issuer, SelfSigned, ListDb);
  
positive.code: certificate_chain(DerCert, CertDbHandle, CertsDbRef) when is_binary(DerCert) ->
      ErlCert = public_key:pkix_decode_cert(DerCert, otp),
      Cert = #cert{der=DerCert, otp=ErlCert},
      Res = certificate_chain(ErlCert, DerCert, CertDbHandle, CertsDbRef, [Cert], []),
      to_der(certificate_chain, Res);
  certificate_chain(OtpCert, CertDbHandle, CertsDbRef) ->
      DerCert = public_key:pkix_encode('OTPCertificate', OtpCert, otp),
      Cert = #cert{der=DerCert, otp=OtpCert},
      Res = certificate_chain(OtpCert, DerCert, CertDbHandle, CertsDbRef, [Cert], []),
      to_der(certificate_chain, Res).
  
  %%--------------------------------------------------------------------
  
negative.code: %%--------------------------------------------------------------------
  %%% Internal functions
  %%--------------------------------------------------------------------
  certificate_chain(#cert{otp=OtpCert}=Cert, CertDbHandle, CertsDbRef, Chain, ListDb) ->
      IssuerAndSelfSigned = 
  	case public_key:pkix_is_self_signed(OtpCert) of
  	    true ->
  