anchor.diff:  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], []),
  +    Res = certificate_chain(Cert, 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], []),
  +    Res = certificate_chain(Cert, CertDbHandle, CertsDbRef, [Cert], []),
       to_der(certificate_chain, Res).
   
   %%--------------------------------------------------------------------
  
positive.code: %%--------------------------------------------------------------------
  %%% Internal functions
  %%--------------------------------------------------------------------
  certificate_chain(OtpCert, BinCert, CertDbHandle, CertsDbRef, Chain, ListDb) ->
      IssuerAndSelfSigned = 
  	case public_key:pkix_is_self_signed(OtpCert) of
  	    true ->
  
negative.code: 				      subjectPublicKey = Key}) ->
      {Key, Params}.
  
  other_issuer(#cert{otp=OtpCert}=Cert, CertDbHandle, CertDbRef) ->
      case public_key:pkix_issuer_id(OtpCert, other) of
  	{ok, IssuerId} ->
  	    {other, IssuerId};
  	{error, issuer_not_found} ->
  	    case find_issuer(Cert, CertDbHandle, CertDbRef, []) of
  		{ok, IssuerId} ->
  		    {other, IssuerId};
  		Other ->
  