 
     %__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


      _ -> false
    end)
  end

  defp private_key_from_base64(nil), do: nil
  defp private_key_from_base64(encoded_key) do
    case Base.decode64(encoded_key) do
      {:ok, key_data} ->
        :public_key.pem_decode(key_data)
        |> Enum.find_value(fn
           {type, data, _} when type in @private_key_atoms -> {type, data}
            _ -> false
        end)
      _ -> nil
      end
  end


end
