 
     %__MODULE__{
       url: cluster["server"],
-      ca_cert: cert_from_pem(cluster["certificate-authority"], basepath),
+      ca_cert: get_cert(cluster, basepath),
       auth: auth_from_user(user, basepath)
     }
   end

    %Kazan.Server.CertificateAuth{
      certificate: cert_from_pem(cert_file, basepath),
      key: private_key_from_pem(key_file, basepath)
    }
  end


  @spec find_by_name([Map.t], String.t) :: Map.t
  defp find_by_name(elems, name) do
    Enum.find(elems, fn (elem) -> elem["name"] == name end)
  end

  @spec get_cert(Map.t, String.t) :: binary
  defp get_cert(%{"certificate-authority" => certfile}, basepath) do
    cert_from_pem(certfile, basepath)
  end

  defp get_cert(%{"certificate-authority-data" => certdata}, _) do
    cert_from_base64(certdata)
  end

  @spec auth_from_user(Map.t, String.t) :: auth_t
