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