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.DtlsConnectionT;
26 
27 public  import gio.AsyncResultIF;
28 public  import gio.Cancellable;
29 public  import gio.TlsCertificate;
30 public  import gio.TlsDatabase;
31 public  import gio.TlsInteraction;
32 public  import gio.c.functions;
33 public  import gio.c.types;
34 public  import glib.ErrorG;
35 public  import glib.GException;
36 public  import glib.Str;
37 public  import gobject.ObjectG;
38 public  import gobject.Signals;
39 public  import gtkc.giotypes;
40 public  import std.algorithm;
41 
42 
43 /**
44  * #GDtlsConnection is the base DTLS connection class type, which wraps
45  * a #GDatagramBased and provides DTLS encryption on top of it. Its
46  * subclasses, #GDtlsClientConnection and #GDtlsServerConnection,
47  * implement client-side and server-side DTLS, respectively.
48  * 
49  * For TLS support, see #GTlsConnection.
50  * 
51  * As DTLS is datagram based, #GDtlsConnection implements #GDatagramBased,
52  * presenting a datagram-socket-like API for the encrypted connection. This
53  * operates over a base datagram connection, which is also a #GDatagramBased
54  * (#GDtlsConnection:base-socket).
55  * 
56  * To close a DTLS connection, use g_dtls_connection_close().
57  * 
58  * Neither #GDtlsServerConnection or #GDtlsClientConnection set the peer address
59  * on their base #GDatagramBased if it is a #GSocket — it is up to the caller to
60  * do that if they wish. If they do not, and g_socket_close() is called on the
61  * base socket, the #GDtlsConnection will not raise a %G_IO_ERROR_NOT_CONNECTED
62  * error on further I/O.
63  *
64  * Since: 2.48
65  */
66 public template DtlsConnectionT(TStruct)
67 {
68 	/** Get the main Gtk struct */
69 	public GDtlsConnection* getDtlsConnectionStruct(bool transferOwnership = false)
70 	{
71 		if (transferOwnership)
72 			ownedRef = false;
73 		return cast(GDtlsConnection*)getStruct();
74 	}
75 
76 
77 	/**
78 	 * Close the DTLS connection. This is equivalent to calling
79 	 * g_dtls_connection_shutdown() to shut down both sides of the connection.
80 	 *
81 	 * Closing a #GDtlsConnection waits for all buffered but untransmitted data to
82 	 * be sent before it completes. It then sends a `close_notify` DTLS alert to the
83 	 * peer and may wait for a `close_notify` to be received from the peer. It does
84 	 * not close the underlying #GDtlsConnection:base-socket; that must be closed
85 	 * separately.
86 	 *
87 	 * Once @conn is closed, all other operations will return %G_IO_ERROR_CLOSED.
88 	 * Closing a #GDtlsConnection multiple times will not return an error.
89 	 *
90 	 * #GDtlsConnections will be automatically closed when the last reference is
91 	 * dropped, but you might want to call this function to make sure resources are
92 	 * released as early as possible.
93 	 *
94 	 * If @cancellable is cancelled, the #GDtlsConnection may be left
95 	 * partially-closed and any pending untransmitted data may be lost. Call
96 	 * g_dtls_connection_close() again to complete closing the #GDtlsConnection.
97 	 *
98 	 * Params:
99 	 *     cancellable = a #GCancellable, or %NULL
100 	 *
101 	 * Returns: %TRUE on success, %FALSE otherwise
102 	 *
103 	 * Since: 2.48
104 	 *
105 	 * Throws: GException on failure.
106 	 */
107 	public bool close(Cancellable cancellable)
108 	{
109 		GError* err = null;
110 
111 		auto __p = g_dtls_connection_close(getDtlsConnectionStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
112 
113 		if (err !is null)
114 		{
115 			throw new GException( new ErrorG(err) );
116 		}
117 
118 		return __p;
119 	}
120 
121 	/**
122 	 * Asynchronously close the DTLS connection. See g_dtls_connection_close() for
123 	 * more information.
124 	 *
125 	 * Params:
126 	 *     ioPriority = the [I/O priority][io-priority] of the request
127 	 *     cancellable = a #GCancellable, or %NULL
128 	 *     callback = callback to call when the close operation is complete
129 	 *     userData = the data to pass to the callback function
130 	 *
131 	 * Since: 2.48
132 	 */
133 	public void closeAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
134 	{
135 		g_dtls_connection_close_async(getDtlsConnectionStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
136 	}
137 
138 	/**
139 	 * Finish an asynchronous TLS close operation. See g_dtls_connection_close()
140 	 * for more information.
141 	 *
142 	 * Params:
143 	 *     result = a #GAsyncResult
144 	 *
145 	 * Returns: %TRUE on success, %FALSE on failure, in which
146 	 *     case @error will be set
147 	 *
148 	 * Since: 2.48
149 	 *
150 	 * Throws: GException on failure.
151 	 */
152 	public bool closeFinish(AsyncResultIF result)
153 	{
154 		GError* err = null;
155 
156 		auto __p = g_dtls_connection_close_finish(getDtlsConnectionStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
157 
158 		if (err !is null)
159 		{
160 			throw new GException( new ErrorG(err) );
161 		}
162 
163 		return __p;
164 	}
165 
166 	/**
167 	 * Used by #GDtlsConnection implementations to emit the
168 	 * #GDtlsConnection::accept-certificate signal.
169 	 *
170 	 * Params:
171 	 *     peerCert = the peer's #GTlsCertificate
172 	 *     errors = the problems with @peer_cert
173 	 *
174 	 * Returns: %TRUE if one of the signal handlers has returned
175 	 *     %TRUE to accept @peer_cert
176 	 *
177 	 * Since: 2.48
178 	 */
179 	public bool emitAcceptCertificate(TlsCertificate peerCert, GTlsCertificateFlags errors)
180 	{
181 		return g_dtls_connection_emit_accept_certificate(getDtlsConnectionStruct(), (peerCert is null) ? null : peerCert.getTlsCertificateStruct(), errors) != 0;
182 	}
183 
184 	/**
185 	 * Gets @conn's certificate, as set by
186 	 * g_dtls_connection_set_certificate().
187 	 *
188 	 * Returns: @conn's certificate, or %NULL
189 	 *
190 	 * Since: 2.48
191 	 */
192 	public TlsCertificate getCertificate()
193 	{
194 		auto __p = g_dtls_connection_get_certificate(getDtlsConnectionStruct());
195 
196 		if(__p is null)
197 		{
198 			return null;
199 		}
200 
201 		return ObjectG.getDObject!(TlsCertificate)(cast(GTlsCertificate*) __p);
202 	}
203 
204 	/**
205 	 * Gets the certificate database that @conn uses to verify
206 	 * peer certificates. See g_dtls_connection_set_database().
207 	 *
208 	 * Returns: the certificate database that @conn uses or %NULL
209 	 *
210 	 * Since: 2.48
211 	 */
212 	public TlsDatabase getDatabase()
213 	{
214 		auto __p = g_dtls_connection_get_database(getDtlsConnectionStruct());
215 
216 		if(__p is null)
217 		{
218 			return null;
219 		}
220 
221 		return ObjectG.getDObject!(TlsDatabase)(cast(GTlsDatabase*) __p);
222 	}
223 
224 	/**
225 	 * Get the object that will be used to interact with the user. It will be used
226 	 * for things like prompting the user for passwords. If %NULL is returned, then
227 	 * no user interaction will occur for this connection.
228 	 *
229 	 * Returns: The interaction object.
230 	 *
231 	 * Since: 2.48
232 	 */
233 	public TlsInteraction getInteraction()
234 	{
235 		auto __p = g_dtls_connection_get_interaction(getDtlsConnectionStruct());
236 
237 		if(__p is null)
238 		{
239 			return null;
240 		}
241 
242 		return ObjectG.getDObject!(TlsInteraction)(cast(GTlsInteraction*) __p);
243 	}
244 
245 	/**
246 	 * Gets the name of the application-layer protocol negotiated during
247 	 * the handshake.
248 	 *
249 	 * If the peer did not use the ALPN extension, or did not advertise a
250 	 * protocol that matched one of @conn's protocols, or the TLS backend
251 	 * does not support ALPN, then this will be %NULL. See
252 	 * g_dtls_connection_set_advertised_protocols().
253 	 *
254 	 * Returns: the negotiated protocol, or %NULL
255 	 *
256 	 * Since: 2.60
257 	 */
258 	public string getNegotiatedProtocol()
259 	{
260 		return Str.toString(g_dtls_connection_get_negotiated_protocol(getDtlsConnectionStruct()));
261 	}
262 
263 	/**
264 	 * Gets @conn's peer's certificate after the handshake has completed.
265 	 * (It is not set during the emission of
266 	 * #GDtlsConnection::accept-certificate.)
267 	 *
268 	 * Returns: @conn's peer's certificate, or %NULL
269 	 *
270 	 * Since: 2.48
271 	 */
272 	public TlsCertificate getPeerCertificate()
273 	{
274 		auto __p = g_dtls_connection_get_peer_certificate(getDtlsConnectionStruct());
275 
276 		if(__p is null)
277 		{
278 			return null;
279 		}
280 
281 		return ObjectG.getDObject!(TlsCertificate)(cast(GTlsCertificate*) __p);
282 	}
283 
284 	/**
285 	 * Gets the errors associated with validating @conn's peer's
286 	 * certificate, after the handshake has completed. (It is not set
287 	 * during the emission of #GDtlsConnection::accept-certificate.)
288 	 *
289 	 * Returns: @conn's peer's certificate errors
290 	 *
291 	 * Since: 2.48
292 	 */
293 	public GTlsCertificateFlags getPeerCertificateErrors()
294 	{
295 		return g_dtls_connection_get_peer_certificate_errors(getDtlsConnectionStruct());
296 	}
297 
298 	/**
299 	 * Gets @conn rehandshaking mode. See
300 	 * g_dtls_connection_set_rehandshake_mode() for details.
301 	 *
302 	 * Deprecated: Changing the rehandshake mode is no longer
303 	 * required for compatibility. Also, rehandshaking has been removed
304 	 * from the TLS protocol in TLS 1.3.
305 	 *
306 	 * Returns: %G_TLS_REHANDSHAKE_SAFELY
307 	 *
308 	 * Since: 2.48
309 	 */
310 	public GTlsRehandshakeMode getRehandshakeMode()
311 	{
312 		return g_dtls_connection_get_rehandshake_mode(getDtlsConnectionStruct());
313 	}
314 
315 	/**
316 	 * Tests whether or not @conn expects a proper TLS close notification
317 	 * when the connection is closed. See
318 	 * g_dtls_connection_set_require_close_notify() for details.
319 	 *
320 	 * Returns: %TRUE if @conn requires a proper TLS close notification.
321 	 *
322 	 * Since: 2.48
323 	 */
324 	public bool getRequireCloseNotify()
325 	{
326 		return g_dtls_connection_get_require_close_notify(getDtlsConnectionStruct()) != 0;
327 	}
328 
329 	/**
330 	 * Attempts a TLS handshake on @conn.
331 	 *
332 	 * On the client side, it is never necessary to call this method;
333 	 * although the connection needs to perform a handshake after
334 	 * connecting, #GDtlsConnection will handle this for you automatically
335 	 * when you try to send or receive data on the connection. You can call
336 	 * g_dtls_connection_handshake() manually if you want to know whether
337 	 * the initial handshake succeeded or failed (as opposed to just
338 	 * immediately trying to use @conn to read or write, in which case,
339 	 * if it fails, it may not be possible to tell if it failed before
340 	 * or after completing the handshake), but beware that servers may reject
341 	 * client authentication after the handshake has completed, so a
342 	 * successful handshake does not indicate the connection will be usable.
343 	 *
344 	 * Likewise, on the server side, although a handshake is necessary at
345 	 * the beginning of the communication, you do not need to call this
346 	 * function explicitly unless you want clearer error reporting.
347 	 *
348 	 * Previously, calling g_dtls_connection_handshake() after the initial
349 	 * handshake would trigger a rehandshake; however, this usage was
350 	 * deprecated in GLib 2.60 because rehandshaking was removed from the
351 	 * TLS protocol in TLS 1.3. Since GLib 2.64, calling this function after
352 	 * the initial handshake will no longer do anything.
353 	 *
354 	 * #GDtlsConnection::accept_certificate may be emitted during the
355 	 * handshake.
356 	 *
357 	 * Params:
358 	 *     cancellable = a #GCancellable, or %NULL
359 	 *
360 	 * Returns: success or failure
361 	 *
362 	 * Since: 2.48
363 	 *
364 	 * Throws: GException on failure.
365 	 */
366 	public bool handshake(Cancellable cancellable)
367 	{
368 		GError* err = null;
369 
370 		auto __p = g_dtls_connection_handshake(getDtlsConnectionStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
371 
372 		if (err !is null)
373 		{
374 			throw new GException( new ErrorG(err) );
375 		}
376 
377 		return __p;
378 	}
379 
380 	/**
381 	 * Asynchronously performs a TLS handshake on @conn. See
382 	 * g_dtls_connection_handshake() for more information.
383 	 *
384 	 * Params:
385 	 *     ioPriority = the [I/O priority][io-priority] of the request
386 	 *     cancellable = a #GCancellable, or %NULL
387 	 *     callback = callback to call when the handshake is complete
388 	 *     userData = the data to pass to the callback function
389 	 *
390 	 * Since: 2.48
391 	 */
392 	public void handshakeAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
393 	{
394 		g_dtls_connection_handshake_async(getDtlsConnectionStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
395 	}
396 
397 	/**
398 	 * Finish an asynchronous TLS handshake operation. See
399 	 * g_dtls_connection_handshake() for more information.
400 	 *
401 	 * Params:
402 	 *     result = a #GAsyncResult.
403 	 *
404 	 * Returns: %TRUE on success, %FALSE on failure, in which
405 	 *     case @error will be set.
406 	 *
407 	 * Since: 2.48
408 	 *
409 	 * Throws: GException on failure.
410 	 */
411 	public bool handshakeFinish(AsyncResultIF result)
412 	{
413 		GError* err = null;
414 
415 		auto __p = g_dtls_connection_handshake_finish(getDtlsConnectionStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
416 
417 		if (err !is null)
418 		{
419 			throw new GException( new ErrorG(err) );
420 		}
421 
422 		return __p;
423 	}
424 
425 	/**
426 	 * Sets the list of application-layer protocols to advertise that the
427 	 * caller is willing to speak on this connection. The
428 	 * Application-Layer Protocol Negotiation (ALPN) extension will be
429 	 * used to negotiate a compatible protocol with the peer; use
430 	 * g_dtls_connection_get_negotiated_protocol() to find the negotiated
431 	 * protocol after the handshake.  Specifying %NULL for the the value
432 	 * of @protocols will disable ALPN negotiation.
433 	 *
434 	 * See [IANA TLS ALPN Protocol IDs](https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids)
435 	 * for a list of registered protocol IDs.
436 	 *
437 	 * Params:
438 	 *     protocols = a %NULL-terminated
439 	 *         array of ALPN protocol names (eg, "http/1.1", "h2"), or %NULL
440 	 *
441 	 * Since: 2.60
442 	 */
443 	public void setAdvertisedProtocols(string[] protocols)
444 	{
445 		g_dtls_connection_set_advertised_protocols(getDtlsConnectionStruct(), Str.toStringzArray(protocols));
446 	}
447 
448 	/**
449 	 * This sets the certificate that @conn will present to its peer
450 	 * during the TLS handshake. For a #GDtlsServerConnection, it is
451 	 * mandatory to set this, and that will normally be done at construct
452 	 * time.
453 	 *
454 	 * For a #GDtlsClientConnection, this is optional. If a handshake fails
455 	 * with %G_TLS_ERROR_CERTIFICATE_REQUIRED, that means that the server
456 	 * requires a certificate, and if you try connecting again, you should
457 	 * call this method first. You can call
458 	 * g_dtls_client_connection_get_accepted_cas() on the failed connection
459 	 * to get a list of Certificate Authorities that the server will
460 	 * accept certificates from.
461 	 *
462 	 * (It is also possible that a server will allow the connection with
463 	 * or without a certificate; in that case, if you don't provide a
464 	 * certificate, you can tell that the server requested one by the fact
465 	 * that g_dtls_client_connection_get_accepted_cas() will return
466 	 * non-%NULL.)
467 	 *
468 	 * Params:
469 	 *     certificate = the certificate to use for @conn
470 	 *
471 	 * Since: 2.48
472 	 */
473 	public void setCertificate(TlsCertificate certificate)
474 	{
475 		g_dtls_connection_set_certificate(getDtlsConnectionStruct(), (certificate is null) ? null : certificate.getTlsCertificateStruct());
476 	}
477 
478 	/**
479 	 * Sets the certificate database that is used to verify peer certificates.
480 	 * This is set to the default database by default. See
481 	 * g_tls_backend_get_default_database(). If set to %NULL, then
482 	 * peer certificate validation will always set the
483 	 * %G_TLS_CERTIFICATE_UNKNOWN_CA error (meaning
484 	 * #GDtlsConnection::accept-certificate will always be emitted on
485 	 * client-side connections, unless that bit is not set in
486 	 * #GDtlsClientConnection:validation-flags).
487 	 *
488 	 * Params:
489 	 *     database = a #GTlsDatabase
490 	 *
491 	 * Since: 2.48
492 	 */
493 	public void setDatabase(TlsDatabase database)
494 	{
495 		g_dtls_connection_set_database(getDtlsConnectionStruct(), (database is null) ? null : database.getTlsDatabaseStruct());
496 	}
497 
498 	/**
499 	 * Set the object that will be used to interact with the user. It will be used
500 	 * for things like prompting the user for passwords.
501 	 *
502 	 * The @interaction argument will normally be a derived subclass of
503 	 * #GTlsInteraction. %NULL can also be provided if no user interaction
504 	 * should occur for this connection.
505 	 *
506 	 * Params:
507 	 *     interaction = an interaction object, or %NULL
508 	 *
509 	 * Since: 2.48
510 	 */
511 	public void setInteraction(TlsInteraction interaction)
512 	{
513 		g_dtls_connection_set_interaction(getDtlsConnectionStruct(), (interaction is null) ? null : interaction.getTlsInteractionStruct());
514 	}
515 
516 	/**
517 	 * Since GLib 2.64, changing the rehandshake mode is no longer supported
518 	 * and will have no effect. With TLS 1.3, rehandshaking has been removed from
519 	 * the TLS protocol, replaced by separate post-handshake authentication and
520 	 * rekey operations.
521 	 *
522 	 * Deprecated: Changing the rehandshake mode is no longer
523 	 * required for compatibility. Also, rehandshaking has been removed
524 	 * from the TLS protocol in TLS 1.3.
525 	 *
526 	 * Params:
527 	 *     mode = the rehandshaking mode
528 	 *
529 	 * Since: 2.48
530 	 */
531 	public void setRehandshakeMode(GTlsRehandshakeMode mode)
532 	{
533 		g_dtls_connection_set_rehandshake_mode(getDtlsConnectionStruct(), mode);
534 	}
535 
536 	/**
537 	 * Sets whether or not @conn expects a proper TLS close notification
538 	 * before the connection is closed. If this is %TRUE (the default),
539 	 * then @conn will expect to receive a TLS close notification from its
540 	 * peer before the connection is closed, and will return a
541 	 * %G_TLS_ERROR_EOF error if the connection is closed without proper
542 	 * notification (since this may indicate a network error, or
543 	 * man-in-the-middle attack).
544 	 *
545 	 * In some protocols, the application will know whether or not the
546 	 * connection was closed cleanly based on application-level data
547 	 * (because the application-level data includes a length field, or is
548 	 * somehow self-delimiting); in this case, the close notify is
549 	 * redundant and may be omitted. You
550 	 * can use g_dtls_connection_set_require_close_notify() to tell @conn
551 	 * to allow an "unannounced" connection close, in which case the close
552 	 * will show up as a 0-length read, as in a non-TLS
553 	 * #GDatagramBased, and it is up to the application to check that
554 	 * the data has been fully received.
555 	 *
556 	 * Note that this only affects the behavior when the peer closes the
557 	 * connection; when the application calls g_dtls_connection_close_async() on
558 	 * @conn itself, this will send a close notification regardless of the
559 	 * setting of this property. If you explicitly want to do an unclean
560 	 * close, you can close @conn's #GDtlsConnection:base-socket rather
561 	 * than closing @conn itself.
562 	 *
563 	 * Params:
564 	 *     requireCloseNotify = whether or not to require close notification
565 	 *
566 	 * Since: 2.48
567 	 */
568 	public void setRequireCloseNotify(bool requireCloseNotify)
569 	{
570 		g_dtls_connection_set_require_close_notify(getDtlsConnectionStruct(), requireCloseNotify);
571 	}
572 
573 	/**
574 	 * Shut down part or all of a DTLS connection.
575 	 *
576 	 * If @shutdown_read is %TRUE then the receiving side of the connection is shut
577 	 * down, and further reading is disallowed. Subsequent calls to
578 	 * g_datagram_based_receive_messages() will return %G_IO_ERROR_CLOSED.
579 	 *
580 	 * If @shutdown_write is %TRUE then the sending side of the connection is shut
581 	 * down, and further writing is disallowed. Subsequent calls to
582 	 * g_datagram_based_send_messages() will return %G_IO_ERROR_CLOSED.
583 	 *
584 	 * It is allowed for both @shutdown_read and @shutdown_write to be TRUE — this
585 	 * is equivalent to calling g_dtls_connection_close().
586 	 *
587 	 * If @cancellable is cancelled, the #GDtlsConnection may be left
588 	 * partially-closed and any pending untransmitted data may be lost. Call
589 	 * g_dtls_connection_shutdown() again to complete closing the #GDtlsConnection.
590 	 *
591 	 * Params:
592 	 *     shutdownRead = %TRUE to stop reception of incoming datagrams
593 	 *     shutdownWrite = %TRUE to stop sending outgoing datagrams
594 	 *     cancellable = a #GCancellable, or %NULL
595 	 *
596 	 * Returns: %TRUE on success, %FALSE otherwise
597 	 *
598 	 * Since: 2.48
599 	 *
600 	 * Throws: GException on failure.
601 	 */
602 	public bool shutdown(bool shutdownRead, bool shutdownWrite, Cancellable cancellable)
603 	{
604 		GError* err = null;
605 
606 		auto __p = g_dtls_connection_shutdown(getDtlsConnectionStruct(), shutdownRead, shutdownWrite, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
607 
608 		if (err !is null)
609 		{
610 			throw new GException( new ErrorG(err) );
611 		}
612 
613 		return __p;
614 	}
615 
616 	/**
617 	 * Asynchronously shut down part or all of the DTLS connection. See
618 	 * g_dtls_connection_shutdown() for more information.
619 	 *
620 	 * Params:
621 	 *     shutdownRead = %TRUE to stop reception of incoming datagrams
622 	 *     shutdownWrite = %TRUE to stop sending outgoing datagrams
623 	 *     ioPriority = the [I/O priority][io-priority] of the request
624 	 *     cancellable = a #GCancellable, or %NULL
625 	 *     callback = callback to call when the shutdown operation is complete
626 	 *     userData = the data to pass to the callback function
627 	 *
628 	 * Since: 2.48
629 	 */
630 	public void shutdownAsync(bool shutdownRead, bool shutdownWrite, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
631 	{
632 		g_dtls_connection_shutdown_async(getDtlsConnectionStruct(), shutdownRead, shutdownWrite, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
633 	}
634 
635 	/**
636 	 * Finish an asynchronous TLS shutdown operation. See
637 	 * g_dtls_connection_shutdown() for more information.
638 	 *
639 	 * Params:
640 	 *     result = a #GAsyncResult
641 	 *
642 	 * Returns: %TRUE on success, %FALSE on failure, in which
643 	 *     case @error will be set
644 	 *
645 	 * Since: 2.48
646 	 *
647 	 * Throws: GException on failure.
648 	 */
649 	public bool shutdownFinish(AsyncResultIF result)
650 	{
651 		GError* err = null;
652 
653 		auto __p = g_dtls_connection_shutdown_finish(getDtlsConnectionStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
654 
655 		if (err !is null)
656 		{
657 			throw new GException( new ErrorG(err) );
658 		}
659 
660 		return __p;
661 	}
662 
663 	/**
664 	 * Emitted during the TLS handshake after the peer certificate has
665 	 * been received. You can examine @peer_cert's certification path by
666 	 * calling g_tls_certificate_get_issuer() on it.
667 	 *
668 	 * For a client-side connection, @peer_cert is the server's
669 	 * certificate, and the signal will only be emitted if the
670 	 * certificate was not acceptable according to @conn's
671 	 * #GDtlsClientConnection:validation_flags. If you would like the
672 	 * certificate to be accepted despite @errors, return %TRUE from the
673 	 * signal handler. Otherwise, if no handler accepts the certificate,
674 	 * the handshake will fail with %G_TLS_ERROR_BAD_CERTIFICATE.
675 	 *
676 	 * For a server-side connection, @peer_cert is the certificate
677 	 * presented by the client, if this was requested via the server's
678 	 * #GDtlsServerConnection:authentication_mode. On the server side,
679 	 * the signal is always emitted when the client presents a
680 	 * certificate, and the certificate will only be accepted if a
681 	 * handler returns %TRUE.
682 	 *
683 	 * Note that if this signal is emitted as part of asynchronous I/O
684 	 * in the main thread, then you should not attempt to interact with
685 	 * the user before returning from the signal handler. If you want to
686 	 * let the user decide whether or not to accept the certificate, you
687 	 * would have to return %FALSE from the signal handler on the first
688 	 * attempt, and then after the connection attempt returns a
689 	 * %G_TLS_ERROR_BAD_CERTIFICATE, you can interact with the user, and
690 	 * if the user decides to accept the certificate, remember that fact,
691 	 * create a new connection, and return %TRUE from the signal handler
692 	 * the next time.
693 	 *
694 	 * If you are doing I/O in another thread, you do not
695 	 * need to worry about this, and can simply block in the signal
696 	 * handler until the UI thread returns an answer.
697 	 *
698 	 * Params:
699 	 *     peerCert = the peer's #GTlsCertificate
700 	 *     errors = the problems with @peer_cert.
701 	 *
702 	 * Returns: %TRUE to accept @peer_cert (which will also
703 	 *     immediately end the signal emission). %FALSE to allow the signal
704 	 *     emission to continue, which will cause the handshake to fail if
705 	 *     no one else overrides it.
706 	 *
707 	 * Since: 2.48
708 	 */
709 	gulong addOnAcceptCertificate(bool delegate(TlsCertificate, GTlsCertificateFlags, DtlsConnectionIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
710 	{
711 		return Signals.connect(this, "accept-certificate", dlg, connectFlags ^ ConnectFlags.SWAPPED);
712 	}
713 }