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 	 * Copies session state from one connection to another. This is
58 	 * not normally needed, but may be used when the same session
59 	 * needs to be used between different endpoints as is required
60 	 * by some protocols such as FTP over TLS. @source should have
61 	 * already completed a handshake, and @conn should not have
62 	 * completed a handshake.
63 	 *
64 	 * Params:
65 	 *     source = a #GTlsClientConnection
66 	 *
67 	 * Since: 2.46
68 	 */
69 	public void copySessionState(TlsClientConnectionIF source)
70 	{
71 		g_tls_client_connection_copy_session_state(getTlsClientConnectionStruct(), (source is null) ? null : source.getTlsClientConnectionStruct());
72 	}
73 
74 	/**
75 	 * Gets the list of distinguished names of the Certificate Authorities
76 	 * that the server will accept certificates from. This will be set
77 	 * during the TLS handshake if the server requests a certificate.
78 	 * Otherwise, it will be %NULL.
79 	 *
80 	 * Each item in the list is a #GByteArray which contains the complete
81 	 * subject DN of the certificate authority.
82 	 *
83 	 * Returns: the list of
84 	 *     CA DNs. You should unref each element with g_byte_array_unref() and then
85 	 *     the free the list with g_list_free().
86 	 *
87 	 * Since: 2.28
88 	 */
89 	public ListG getAcceptedCas()
90 	{
91 		auto p = g_tls_client_connection_get_accepted_cas(getTlsClientConnectionStruct());
92 
93 		if(p is null)
94 		{
95 			return null;
96 		}
97 
98 		return new ListG(cast(GList*) p, true);
99 	}
100 
101 	/**
102 	 * Gets @conn's expected server identity
103 	 *
104 	 * Returns: a #GSocketConnectable describing the
105 	 *     expected server identity, or %NULL if the expected identity is not
106 	 *     known.
107 	 *
108 	 * Since: 2.28
109 	 */
110 	public SocketConnectableIF getServerIdentity()
111 	{
112 		auto p = g_tls_client_connection_get_server_identity(getTlsClientConnectionStruct());
113 
114 		if(p is null)
115 		{
116 			return null;
117 		}
118 
119 		return ObjectG.getDObject!(SocketConnectableIF)(cast(GSocketConnectable*) p);
120 	}
121 
122 	/**
123 	 * Gets whether @conn will force the lowest-supported TLS protocol
124 	 * version rather than attempt to negotiate the highest mutually-
125 	 * supported version of TLS; see g_tls_client_connection_set_use_ssl3().
126 	 *
127 	 * Deprecated: SSL 3.0 is insecure, and this function does not
128 	 * actually indicate whether it is enabled.
129 	 *
130 	 * Returns: whether @conn will use the lowest-supported TLS protocol version
131 	 *
132 	 * Since: 2.28
133 	 */
134 	public bool getUseSsl3()
135 	{
136 		return g_tls_client_connection_get_use_ssl3(getTlsClientConnectionStruct()) != 0;
137 	}
138 
139 	/**
140 	 * Gets @conn's validation flags
141 	 *
142 	 * Returns: the validation flags
143 	 *
144 	 * Since: 2.28
145 	 */
146 	public GTlsCertificateFlags getValidationFlags()
147 	{
148 		return g_tls_client_connection_get_validation_flags(getTlsClientConnectionStruct());
149 	}
150 
151 	/**
152 	 * Sets @conn's expected server identity, which is used both to tell
153 	 * servers on virtual hosts which certificate to present, and also
154 	 * to let @conn know what name to look for in the certificate when
155 	 * performing %G_TLS_CERTIFICATE_BAD_IDENTITY validation, if enabled.
156 	 *
157 	 * Params:
158 	 *     identity = a #GSocketConnectable describing the expected server identity
159 	 *
160 	 * Since: 2.28
161 	 */
162 	public void setServerIdentity(SocketConnectableIF identity)
163 	{
164 		g_tls_client_connection_set_server_identity(getTlsClientConnectionStruct(), (identity is null) ? null : identity.getSocketConnectableStruct());
165 	}
166 
167 	/**
168 	 * If @use_ssl3 is %TRUE, this forces @conn to use the lowest-supported
169 	 * TLS protocol version rather than trying to properly negotiate the
170 	 * highest mutually-supported protocol version with the peer. This can
171 	 * be used when talking to broken TLS servers that exhibit protocol
172 	 * version intolerance.
173 	 *
174 	 * Be aware that SSL 3.0 is generally disabled by the #GTlsBackend, so
175 	 * the lowest-supported protocol version is probably not SSL 3.0.
176 	 *
177 	 * Deprecated: SSL 3.0 is insecure, and this function does not
178 	 * generally enable or disable it, despite its name.
179 	 *
180 	 * Params:
181 	 *     useSsl3 = whether to use the lowest-supported protocol version
182 	 *
183 	 * Since: 2.28
184 	 */
185 	public void setUseSsl3(bool useSsl3)
186 	{
187 		g_tls_client_connection_set_use_ssl3(getTlsClientConnectionStruct(), useSsl3);
188 	}
189 
190 	/**
191 	 * Sets @conn's validation flags, to override the default set of
192 	 * checks performed when validating a server certificate. By default,
193 	 * %G_TLS_CERTIFICATE_VALIDATE_ALL is used.
194 	 *
195 	 * Params:
196 	 *     flags = the #GTlsCertificateFlags to use
197 	 *
198 	 * Since: 2.28
199 	 */
200 	public void setValidationFlags(GTlsCertificateFlags flags)
201 	{
202 		g_tls_client_connection_set_validation_flags(getTlsClientConnectionStruct(), flags);
203 	}
204 }