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