store some extra info in GSettingsKeyInfo
[glib.git] / gio / gtlsfiledatabase.c
blob6e6a5c4543fc4441cb0fe1018896ad21254cfd16
1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright © 2010 Collabora, Ltd
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Stef Walter <stefw@collabora.co.uk>
23 #include "config.h"
25 #include "gtlsfiledatabase.h"
27 #include "ginitable.h"
28 #include "gtlsbackend.h"
29 #include "gtlsdatabase.h"
30 #include "glibintl.h"
32 /**
33 * SECTION:gtlsfiledatabase
34 * @short_description: TLS file based database type
35 * @include: gio/gio.h
37 * #GTlsFileDatabase is implemented by #GTlsDatabase objects which load
38 * their certificate information from a file. It is in interface which
39 * TLS library specific subtypes implement.
41 * Since: 2.30
44 /**
45 * GTlsFileDatabase:
47 * Implemented by a #GTlsDatabase which allows you to load certificates
48 * from a file.
50 * Since: 2.30
52 G_DEFINE_INTERFACE (GTlsFileDatabase, g_tls_file_database, G_TYPE_TLS_DATABASE)
54 static void
55 g_tls_file_database_default_init (GTlsFileDatabaseInterface *iface)
57 /**
58 * GTlsFileDatabase:anchors:
60 * The path to a file containing PEM encoded certificate authority
61 * root anchors. The certificates in this file will be treated as
62 * root authorities for the purpose of verifying other certificates
63 * via the g_tls_database_verify_chain() operation.
65 * Since: 2.30
67 g_object_interface_install_property (iface,
68 g_param_spec_string ("anchors",
69 P_("Anchors"),
70 P_("The certificate authority anchor file"),
71 NULL,
72 G_PARAM_READWRITE |
73 G_PARAM_CONSTRUCT |
74 G_PARAM_STATIC_STRINGS));
77 /**
78 * g_tls_file_database_new:
79 * @anchors: filename of anchor certificate authorities.
80 * @error: #GError for error reporting, or %NULL to ignore.
82 * Creates a new #GTlsFileDatabase which uses anchor certificate authorities
83 * in @anchors to verify certificate chains.
85 * The certificates in @anchors must be PEM encoded.
87 * Return value: (transfer full): the new #GTlsFileDatabase, or %NULL on error
89 * Since: 2.30
91 GTlsDatabase*
92 g_tls_file_database_new (const gchar *anchors,
93 GError **error)
95 GObject *database;
96 GTlsBackend *backend;
98 backend = g_tls_backend_get_default ();
99 database = g_initable_new (g_tls_backend_get_file_database_type (backend),
100 NULL, error,
101 "anchors", anchors,
102 NULL);
103 return G_TLS_DATABASE (database);