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 * Conversion parameters: 26 * inFile = GTlsClientConnection.html 27 * outPack = gio 28 * outFile = TlsClientConnection 29 * strct = GTlsClientConnection 30 * realStrct= 31 * ctorStrct=GIOStream 32 * clss = TlsClientConnection 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = GTlsConnection 38 * implements: 39 * prefixes: 40 * - g_tls_client_connection_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - glib.ErrorG 48 * - glib.GException 49 * - glib.ListG 50 * - gio.IOStream 51 * - gio.SocketConnectable 52 * - gio.SocketConnectableIF 53 * structWrap: 54 * - GIOStream* -> IOStream 55 * - GList* -> ListG 56 * - GSocketConnectable* -> SocketConnectableIF 57 * module aliases: 58 * local aliases: 59 * overrides: 60 */ 61 62 module gio.TlsClientConnection; 63 64 public import gtkc.giotypes; 65 66 private import gtkc.gio; 67 private import glib.ConstructionException; 68 private import gobject.ObjectG; 69 70 71 private import glib.Str; 72 private import glib.ErrorG; 73 private import glib.GException; 74 private import glib.ListG; 75 private import gio.IOStream; 76 private import gio.SocketConnectable; 77 private import gio.SocketConnectableIF; 78 79 80 81 private import gio.TlsConnection; 82 83 /** 84 * Description 85 * GTlsClientConnection is the client-side subclass of 86 * GTlsConnection, representing a client-side TLS connection. 87 */ 88 public class TlsClientConnection : TlsConnection 89 { 90 91 /** the main Gtk struct */ 92 protected GTlsClientConnection* gTlsClientConnection; 93 94 95 public GTlsClientConnection* getTlsClientConnectionStruct() 96 { 97 return gTlsClientConnection; 98 } 99 100 101 /** the main Gtk struct as a void* */ 102 protected override void* getStruct() 103 { 104 return cast(void*)gTlsClientConnection; 105 } 106 107 /** 108 * Sets our main struct and passes it to the parent class 109 */ 110 public this (GTlsClientConnection* gTlsClientConnection) 111 { 112 super(cast(GTlsConnection*)gTlsClientConnection); 113 this.gTlsClientConnection = gTlsClientConnection; 114 } 115 116 protected override void setStruct(GObject* obj) 117 { 118 super.setStruct(obj); 119 gTlsClientConnection = cast(GTlsClientConnection*)obj; 120 } 121 122 /** 123 */ 124 125 /** 126 * Creates a new GTlsClientConnection wrapping base_io_stream (which 127 * must have pollable input and output streams) which is assumed to 128 * communicate with the server identified by server_identity. 129 * Since 2.28 130 * Params: 131 * baseIoStream = the GIOStream to wrap 132 * serverIdentity = the expected identity of the server. [allow-none] 133 * Throws: GException on failure. 134 * Throws: ConstructionException GTK+ fails to create the object. 135 */ 136 public this (IOStream baseIoStream, SocketConnectableIF serverIdentity) 137 { 138 // GIOStream * g_tls_client_connection_new (GIOStream *base_io_stream, GSocketConnectable *server_identity, GError **error); 139 GError* err = null; 140 141 auto p = g_tls_client_connection_new((baseIoStream is null) ? null : baseIoStream.getIOStreamStruct(), (serverIdentity is null) ? null : serverIdentity.getSocketConnectableTStruct(), &err); 142 143 if (err !is null) 144 { 145 throw new GException( new ErrorG(err) ); 146 } 147 148 if(p is null) 149 { 150 throw new ConstructionException("null returned by g_tls_client_connection_new((baseIoStream is null) ? null : baseIoStream.getIOStreamStruct(), (serverIdentity is null) ? null : serverIdentity.getSocketConnectableTStruct(), &err)"); 151 } 152 this(cast(GTlsClientConnection*) p); 153 } 154 155 /** 156 * Sets conn's expected server identity, which is used both to tell 157 * servers on virtual hosts which certificate to present, and also 158 * to let conn know what name to look for in the certificate when 159 * performing G_TLS_CERTIFICATE_BAD_IDENTITY validation, if enabled. 160 * Since 2.28 161 * Params: 162 * identity = a GSocketConnectable describing the expected server identity 163 */ 164 public void setServerIdentity(SocketConnectableIF identity) 165 { 166 // void g_tls_client_connection_set_server_identity (GTlsClientConnection *conn, GSocketConnectable *identity); 167 g_tls_client_connection_set_server_identity(gTlsClientConnection, (identity is null) ? null : identity.getSocketConnectableTStruct()); 168 } 169 170 /** 171 * Gets conn's expected server identity 172 * Since 2.28 173 * Returns: a GSocketConnectable describing the expected server identity, or NULL if the expected identity is not known. 174 */ 175 public SocketConnectableIF getServerIdentity() 176 { 177 // GSocketConnectable * g_tls_client_connection_get_server_identity (GTlsClientConnection *conn); 178 auto p = g_tls_client_connection_get_server_identity(gTlsClientConnection); 179 180 if(p is null) 181 { 182 return null; 183 } 184 185 return ObjectG.getDObject!(SocketConnectable, SocketConnectableIF)(cast(GSocketConnectable*) p); 186 } 187 188 /** 189 * Sets conn's validation flags, to override the default set of 190 * checks performed when validating a server certificate. By default, 191 * G_TLS_CERTIFICATE_VALIDATE_ALL is used. 192 * Since 2.28 193 * Params: 194 * flags = the GTlsCertificateFlags to use 195 */ 196 public void setValidationFlags(GTlsCertificateFlags flags) 197 { 198 // void g_tls_client_connection_set_validation_flags (GTlsClientConnection *conn, GTlsCertificateFlags flags); 199 g_tls_client_connection_set_validation_flags(gTlsClientConnection, flags); 200 } 201 202 /** 203 * Gets conn's validation flags 204 * Since 2.28 205 * Returns: the validation flags 206 */ 207 public GTlsCertificateFlags getValidationFlags() 208 { 209 // GTlsCertificateFlags g_tls_client_connection_get_validation_flags (GTlsClientConnection *conn); 210 return g_tls_client_connection_get_validation_flags(gTlsClientConnection); 211 } 212 213 /** 214 * If use_ssl3 is TRUE, this forces conn to use SSL 3.0 rather than 215 * trying to properly negotiate the right version of TLS or SSL to use. 216 * This can be used when talking to servers that do not implement the 217 * fallbacks correctly and which will therefore fail to handshake with 218 * a "modern" TLS handshake attempt. 219 * Since 2.28 220 * Params: 221 * useSsl3 = whether to use SSL 3.0 222 */ 223 public void setUseSsl3(int useSsl3) 224 { 225 // void g_tls_client_connection_set_use_ssl3 (GTlsClientConnection *conn, gboolean use_ssl3); 226 g_tls_client_connection_set_use_ssl3(gTlsClientConnection, useSsl3); 227 } 228 229 /** 230 * Gets whether conn will use SSL 3.0 rather than the 231 * highest-supported version of TLS; see 232 * g_tls_client_connection_set_use_ssl3(). 233 * Since 2.28 234 * Returns: whether conn will use SSL 3.0 235 */ 236 public int getUseSsl3() 237 { 238 // gboolean g_tls_client_connection_get_use_ssl3 (GTlsClientConnection *conn); 239 return g_tls_client_connection_get_use_ssl3(gTlsClientConnection); 240 } 241 242 /** 243 * Gets the list of distinguished names of the Certificate Authorities 244 * that the server will accept certificates from. This will be set 245 * during the TLS handshake if the server requests a certificate. 246 * Otherwise, it will be NULL. 247 * Each item in the list is a GByteArray which contains the complete 248 * subject DN of the certificate authority. 249 * Since 2.28 250 * Returns: the list of CA DNs. You should unref each element with g_byte_array_unref() and then the free the list with g_list_free(). [element-type GByteArray][transfer full] 251 */ 252 public ListG getAcceptedCas() 253 { 254 // GList * g_tls_client_connection_get_accepted_cas (GTlsClientConnection *conn); 255 auto p = g_tls_client_connection_get_accepted_cas(gTlsClientConnection); 256 257 if(p is null) 258 { 259 return null; 260 } 261 262 return ObjectG.getDObject!(ListG)(cast(GList*) p); 263 } 264 }