1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD 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
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gio.TlsClientConnectionT;
26 
27 public  import gio.IOStream;
28 public  import gio.SocketConnectableIF;
29 public  import gio.c.functions;
30 public  import gio.c.types;
31 public  import glib.ConstructionException;
32 public  import glib.ErrorG;
33 public  import glib.GException;
34 public  import glib.ListG;
35 public  import gobject.ObjectG;
36 public  import gtkc.giotypes;
37 
38 
39 /**
40  * #GTlsClientConnection is the client-side subclass of
41  * #GTlsConnection, representing a client-side TLS connection.
42  *
43  * Since: 2.28
44  */
45 public template TlsClientConnectionT(TStruct)
46 {
47 	/** Get the main Gtk struct */
48 	public GTlsClientConnection* getTlsClientConnectionStruct(bool transferOwnership = false)
49 	{
50 		if (transferOwnership)
51 			ownedRef = false;
52 		return cast(GTlsClientConnection*)getStruct();
53 	}
54 
55 
56 	/**
57 	 * Possibly copies session state from one connection to another, for use
58 	 * in TLS session resumption. This is not normally needed, but may be
59 	 * used when the same session needs to be used between different
60 	 * endpoints, as is required by some protocols, such as FTP over TLS.
61 	 * @source should have already completed a handshake and, since TLS 1.3,
62 	 * it should have been used to read data at least once. @conn should not
63 	 * have completed a handshake.
64 	 *
65 	 * It is not possible to know whether a call to this function will
66 	 * actually do anything. Because session resumption is normally used
67 	 * only for performance benefit, the TLS backend might not implement
68 	 * this function. Even if implemented, it may not actually succeed in
69 	 * allowing @conn to resume @source's TLS session, because the server
70 	 * may not have sent a session resumption token to @source, or it may
71 	 * refuse to accept the token from @conn. There is no way to know
72 	 * whether a call to this function is actually successful.
73 	 *
74 	 * Using this function is not required to benefit from session
75 	 * resumption. If the TLS backend supports session resumption, the
76 	 * session will be resumed automatically if it is possible to do so
77 	 * without weakening the privacy guarantees normally provided by TLS,
78 	 * without need to call this function. For example, with TLS 1.3,
79 	 * a session ticket will be automatically copied from any
80 	 * #GTlsClientConnection that has previously received session tickets
81 	 * from the server, provided a ticket is available that has not
82 	 * previously been used for session resumption, since session ticket
83 	 * reuse would be a privacy weakness. Using this function causes the
84 	 * ticket to be copied without regard for privacy considerations.
85 	 *
86 	 * Params:
87 	 *     source = a #GTlsClientConnection
88 	 *
89 	 * Since: 2.46
90 	 */
91 	public void copySessionState(TlsClientConnectionIF source)
92 	{
93 		g_tls_client_connection_copy_session_state(getTlsClientConnectionStruct(), (source is null) ? null : source.getTlsClientConnectionStruct());
94 	}
95 
96 	/**
97 	 * Gets the list of distinguished names of the Certificate Authorities
98 	 * that the server will accept certificates from. This will be set
99 	 * during the TLS handshake if the server requests a certificate.
100 	 * Otherwise, it will be %NULL.
101 	 *
102 	 * Each item in the list is a #GByteArray which contains the complete
103 	 * subject DN of the certificate authority.
104 	 *
105 	 * Returns: the list of
106 	 *     CA DNs. You should unref each element with g_byte_array_unref() and then
107 	 *     the free the list with g_list_free().
108 	 *
109 	 * Since: 2.28
110 	 */
111 	public ListG getAcceptedCas()
112 	{
113 		auto __p = g_tls_client_connection_get_accepted_cas(getTlsClientConnectionStruct());
114 
115 		if(__p is null)
116 		{
117 			return null;
118 		}
119 
120 		return new ListG(cast(GList*) __p, true);
121 	}
122 
123 	/**
124 	 * Gets @conn's expected server identity
125 	 *
126 	 * Returns: a #GSocketConnectable describing the
127 	 *     expected server identity, or %NULL if the expected identity is not
128 	 *     known.
129 	 *
130 	 * Since: 2.28
131 	 */
132 	public SocketConnectableIF getServerIdentity()
133 	{
134 		auto __p = g_tls_client_connection_get_server_identity(getTlsClientConnectionStruct());
135 
136 		if(__p is null)
137 		{
138 			return null;
139 		}
140 
141 		return ObjectG.getDObject!(SocketConnectableIF)(cast(GSocketConnectable*) __p);
142 	}
143 
144 	/**
145 	 * SSL 3.0 is no longer supported. See
146 	 * g_tls_client_connection_set_use_ssl3() for details.
147 	 *
148 	 * Deprecated: SSL 3.0 is insecure.
149 	 *
150 	 * Returns: %FALSE
151 	 *
152 	 * Since: 2.28
153 	 */
154 	public bool getUseSsl3()
155 	{
156 		return g_tls_client_connection_get_use_ssl3(getTlsClientConnectionStruct()) != 0;
157 	}
158 
159 	/**
160 	 * Gets @conn's validation flags
161 	 *
162 	 * Returns: the validation flags
163 	 *
164 	 * Since: 2.28
165 	 */
166 	public GTlsCertificateFlags getValidationFlags()
167 	{
168 		return g_tls_client_connection_get_validation_flags(getTlsClientConnectionStruct());
169 	}
170 
171 	/**
172 	 * Sets @conn's expected server identity, which is used both to tell
173 	 * servers on virtual hosts which certificate to present, and also
174 	 * to let @conn know what name to look for in the certificate when
175 	 * performing %G_TLS_CERTIFICATE_BAD_IDENTITY validation, if enabled.
176 	 *
177 	 * Params:
178 	 *     identity = a #GSocketConnectable describing the expected server identity
179 	 *
180 	 * Since: 2.28
181 	 */
182 	public void setServerIdentity(SocketConnectableIF identity)
183 	{
184 		g_tls_client_connection_set_server_identity(getTlsClientConnectionStruct(), (identity is null) ? null : identity.getSocketConnectableStruct());
185 	}
186 
187 	/**
188 	 * Since GLib 2.42.1, SSL 3.0 is no longer supported.
189 	 *
190 	 * From GLib 2.42.1 through GLib 2.62, this function could be used to
191 	 * force use of TLS 1.0, the lowest-supported TLS protocol version at
192 	 * the time. In the past, this was needed to connect to broken TLS
193 	 * servers that exhibited protocol version intolerance. Such servers
194 	 * are no longer common, and using TLS 1.0 is no longer considered
195 	 * acceptable.
196 	 *
197 	 * Since GLib 2.64, this function does nothing.
198 	 *
199 	 * Deprecated: SSL 3.0 is insecure.
200 	 *
201 	 * Params:
202 	 *     useSsl3 = a #gboolean, ignored
203 	 *
204 	 * Since: 2.28
205 	 */
206 	public void setUseSsl3(bool useSsl3)
207 	{
208 		g_tls_client_connection_set_use_ssl3(getTlsClientConnectionStruct(), useSsl3);
209 	}
210 
211 	/**
212 	 * Sets @conn's validation flags, to override the default set of
213 	 * checks performed when validating a server certificate. By default,
214 	 * %G_TLS_CERTIFICATE_VALIDATE_ALL is used.
215 	 *
216 	 * Params:
217 	 *     flags = the #GTlsCertificateFlags to use
218 	 *
219 	 * Since: 2.28
220 	 */
221 	public void setValidationFlags(GTlsCertificateFlags flags)
222 	{
223 		g_tls_client_connection_set_validation_flags(getTlsClientConnectionStruct(), flags);
224 	}
225 }