anchor.diff:  certificate_chain(DerCert, CertDbHandle, CertsDbRef, Candidates) 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], Candidates),
  +    Res = certificate_chain(Cert, CertDbHandle, CertsDbRef, [Cert], Candidates),
       to_der(certificate_chain, Res);
   certificate_chain(OtpCert, CertDbHandle, CertsDbRef, Candidates) ->
       DerCert = public_key:pkix_encode('OTPCertificate', OtpCert, otp),
       Cert = #cert{der=DerCert, otp=OtpCert},
  -    Res = certificate_chain(Cert, DerCert, CertDbHandle, CertsDbRef, [Cert], Candidates),
  +    Res = certificate_chain(Cert, CertDbHandle, CertsDbRef, [Cert], Candidates),
       to_der(certificate_chain, Res).
   %%--------------------------------------------------------------------
   -spec file_to_certificats(binary(), term()) -> [der_cert()].
  
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 ->
  