Exemplo n.º 1
0
static const gchar *
parse_cert_option_as_pem (JsonObject *options,
                          const gchar *option,
                          GString *pem)
{
  const gchar *problem = NULL;
  const gchar *file;
  const gchar *data;
  gchar *path;

  problem = parse_option_file_or_data (options, option, &file, &data);
  if (problem)
    return problem;

  if (file)
    {
      path = expand_filename (file);

      /* For now we assume file contents are PEM */
      problem = load_pem_contents (path, option, pem);

      g_free (path);
    }
  else if (data)
    {
      /* Format this as PEM of the given type */
      g_string_append (pem, data);
      g_string_append_c (pem, '\n');
    }

  return problem;
}
Exemplo n.º 2
0
static gboolean
parse_cert_option_as_pem (CockpitChannel *self,
                          JsonObject *options,
                          const gchar *option,
                          GString *pem)
{
  gboolean ret = TRUE;
  const gchar *file;
  const gchar *data;
  gchar *path;

  if (!parse_option_file_or_data (self, options, option, &file, &data))
    return FALSE;

  if (file)
    {
      path = expand_filename (file);

      /* For now we assume file contents are PEM */
      ret = load_pem_contents (self, path, option, pem);

      g_free (path);
    }
  else if (data)
    {
      /* Format this as PEM of the given type */
      g_string_append (pem, data);
      g_string_append_c (pem, '\n');
    }

  return ret;
}