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