1/* GIO - GLib Input, Output and Streaming Library
2 *
3 * Copyright (C) 2010 Red Hat, Inc.
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef __G_TLS_CERTIFICATE_H__
22#define __G_TLS_CERTIFICATE_H__
23
24#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
25#error "Only <gio/gio.h> can be included directly."
26#endif
27
28#include <gio/giotypes.h>
29
30G_BEGIN_DECLS
31
32#define G_TYPE_TLS_CERTIFICATE (g_tls_certificate_get_type ())
33#define G_TLS_CERTIFICATE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_CERTIFICATE, GTlsCertificate))
34#define G_TLS_CERTIFICATE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TLS_CERTIFICATE, GTlsCertificateClass))
35#define G_IS_TLS_CERTIFICATE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TLS_CERTIFICATE))
36#define G_IS_TLS_CERTIFICATE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TLS_CERTIFICATE))
37#define G_TLS_CERTIFICATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), G_TYPE_TLS_CERTIFICATE, GTlsCertificateClass))
38
39typedef struct _GTlsCertificateClass GTlsCertificateClass;
40typedef struct _GTlsCertificatePrivate GTlsCertificatePrivate;
41
42struct _GTlsCertificate {
43 GObject parent_instance;
44
45 GTlsCertificatePrivate *priv;
46};
47
48struct _GTlsCertificateClass
49{
50 GObjectClass parent_class;
51
52 GTlsCertificateFlags (* verify) (GTlsCertificate *cert,
53 GSocketConnectable *identity,
54 GTlsCertificate *trusted_ca);
55
56 /*< private >*/
57 /* Padding for future expansion */
58 gpointer padding[8];
59};
60
61GIO_AVAILABLE_IN_ALL
62GType g_tls_certificate_get_type (void) G_GNUC_CONST;
63
64GIO_AVAILABLE_IN_ALL
65GTlsCertificate *g_tls_certificate_new_from_pem (const gchar *data,
66 gssize length,
67 GError **error);
68GIO_AVAILABLE_IN_2_72
69GTlsCertificate *g_tls_certificate_new_from_pkcs12 (const guint8 *data,
70 gsize length,
71 const gchar *password,
72 GError **error);
73GIO_AVAILABLE_IN_2_72
74GTlsCertificate *g_tls_certificate_new_from_file_with_password (const gchar *file,
75 const gchar *password,
76 GError **error);
77GIO_AVAILABLE_IN_ALL
78GTlsCertificate *g_tls_certificate_new_from_file (const gchar *file,
79 GError **error);
80GIO_AVAILABLE_IN_ALL
81GTlsCertificate *g_tls_certificate_new_from_files (const gchar *cert_file,
82 const gchar *key_file,
83 GError **error);
84GIO_AVAILABLE_IN_2_68
85GTlsCertificate *g_tls_certificate_new_from_pkcs11_uris (const gchar *pkcs11_uri,
86 const gchar *private_key_pkcs11_uri,
87 GError **error);
88
89GIO_AVAILABLE_IN_ALL
90GList *g_tls_certificate_list_new_from_file (const gchar *file,
91 GError **error);
92
93GIO_AVAILABLE_IN_ALL
94GTlsCertificate *g_tls_certificate_get_issuer (GTlsCertificate *cert);
95
96GIO_AVAILABLE_IN_ALL
97GTlsCertificateFlags g_tls_certificate_verify (GTlsCertificate *cert,
98 GSocketConnectable *identity,
99 GTlsCertificate *trusted_ca);
100
101GIO_AVAILABLE_IN_2_34
102gboolean g_tls_certificate_is_same (GTlsCertificate *cert_one,
103 GTlsCertificate *cert_two);
104
105GIO_AVAILABLE_IN_2_70
106GDateTime *g_tls_certificate_get_not_valid_before (GTlsCertificate *cert);
107
108GIO_AVAILABLE_IN_2_70
109GDateTime *g_tls_certificate_get_not_valid_after (GTlsCertificate *cert);
110
111GIO_AVAILABLE_IN_2_70
112gchar *g_tls_certificate_get_subject_name (GTlsCertificate *cert);
113
114GIO_AVAILABLE_IN_2_70
115gchar *g_tls_certificate_get_issuer_name (GTlsCertificate *cert);
116
117GIO_AVAILABLE_IN_2_70
118GPtrArray *g_tls_certificate_get_dns_names (GTlsCertificate *cert);
119
120GIO_AVAILABLE_IN_2_70
121GPtrArray *g_tls_certificate_get_ip_addresses (GTlsCertificate *cert);
122
123G_END_DECLS
124
125#endif /* __G_TLS_CERTIFICATE_H__ */
126