1=pod 2 3=head1 NAME 4 5openssl-quic - OpenSSL QUIC 6 7=head1 DESCRIPTION 8 9OpenSSL 3.2 and later features support for the QUIC transport protocol. 10You can use OpenSSL's QUIC capabilities for both client and server applications. 11This man page describes how to let applications use the QUIC protocol using the 12libssl API. 13 14The QUIC protocol maps to the standard SSL API. A QUIC connection is represented 15by an SSL object in the same way that a TLS connection is. Only minimal changes 16are needed to existing applications which use libssl API to bring QUIC protocol 17support in. QUIC clients can use L<OSSL_QUIC_client_method(3)> or 18L<OSSL_QUIC_client_thread_method(3)> with L<SSL_CTX_new(3)>. See below for more 19details about the difference between the two. For servers, there is only one 20option: SSL method L<OSSL_QUIC_server_method(3)> with L<SSL_CTX_new(3)>. 21 22The remainder of this man page discusses, in order: 23 24=over 4 25 26=item 27 28Default stream mode versus multi-stream mode for clients; 29 30=item 31 32The changes to existing libssl APIs which are driven by QUIC-related 33implementation requirements, which existing applications should bear in mind; 34 35=item 36 37Aspects which must be considered by existing applications when adopting QUIC, 38including potential changes which may be needed. 39 40=item 41 42Recommended usage approaches for new applications. 43 44=item 45 46New, QUIC-specific APIs. 47 48=back 49 50=head1 CLIENT MODES OF OPERATION 51 52When a client creates a QUIC connection, by default, it operates in default 53stream mode, which is intended to provide compatibility with existing non-QUIC 54application usage patterns. In this mode, the connection has a single stream 55associated with it. Calls to L<SSL_read(3)> and L<SSL_write(3)> on the QUIC 56connection SSL object read and write from that stream. Whether the stream is 57client-initiated or server-initiated from a QUIC perspective depends on whether 58L<SSL_read(3)> or L<SSL_write(3)> is called first. 59 60Default stream mode is primarily for compatibility with existing applications. 61For new applications utilizing QUIC, it's recommended to disable this mode and 62instead adopt the multi-stream API. See the RECOMMENDATIONS FOR NEW APPLICATIONS 63section for more details. 64 65=head2 Default Stream Mode 66 67A QUIC client connection can be used in either default stream mode or 68multi-stream mode. By default, a newly created QUIC connection SSL object uses 69default stream mode. 70 71In default stream mode, a stream is implicitly created and bound to the QUIC 72connection SSL object; L<SSL_read(3)> and L<SSL_write(3)> calls to the QUIC 73connection SSL object work by default and are mapped to that stream. 74 75When default stream mode is used, any API function which can be called on a QUIC 76stream SSL object can also be called on a QUIC connection SSL object, in which 77case it affects the default stream bound to the connection. 78 79The identity of a QUIC stream, including its stream ID, varies depending on 80whether a stream is client-initiated or server-initiated. In default stream 81mode, if a client application calls L<SSL_read(3)> first before any call to 82L<SSL_write(3)> on the connection, it is assumed that the application protocol 83is using a server-initiated stream, and the L<SSL_read(3)> call will not 84complete (either blocking, or failing appropriately if nonblocking mode is 85configured) until the server initiates a stream. Conversely, if the client 86application calls L<SSL_write(3)> before any call to L<SSL_read(3)> on the 87connection, it is assumed that a client-initiated stream is to be used 88and such a stream is created automatically. 89 90Default stream mode is intended to aid compatibility with legacy applications. 91New applications adopting QUIC should use multi-stream mode, described below, 92and avoid use of the default stream functionality. 93 94It is possible to use additional streams in default stream mode using 95L<SSL_new_stream(3)> and L<SSL_accept_stream(3)>; note that the default incoming 96stream policy will need to be changed using L<SSL_set_incoming_stream_policy(3)> 97in order to use L<SSL_accept_stream(3)> in this case. However, applications 98using additional streams are strongly recommended to use multi-stream mode 99instead. 100 101Calling L<SSL_new_stream(3)> or L<SSL_accept_stream(3)> before a default stream 102has been associated with the QUIC connection SSL object will inhibit future 103creation of a default stream. 104 105=head2 Multi-Stream Mode 106 107The recommended usage mode for new applications adopting QUIC is multi-stream 108mode, in which no default stream is attached to the QUIC connection SSL object 109and attempts to call L<SSL_read(3)> and L<SSL_write(3)> on the QUIC connection 110SSL object fail. Instead, an application calls L<SSL_new_stream(3)> or 111L<SSL_accept_stream(3)> to create individual stream SSL objects for sending and 112receiving application data using L<SSL_read(3)> and L<SSL_write(3)>. 113 114To use multi-stream mode, call L<SSL_set_default_stream_mode(3)> with an 115argument of B<SSL_DEFAULT_STREAM_MODE_NONE>; this function must be called prior 116to initiating the connection. The default stream mode cannot be changed after 117initiating a connection. 118 119When multi-stream mode is used, meaning that no default stream is associated 120with the connection, calls to API functions which are defined as operating on a 121QUIC stream fail if called on the QUIC connection SSL object. For example, calls 122such as L<SSL_write(3)> or L<SSL_get_stream_id(3)> will fail. 123 124=head1 CHANGES TO EXISTING APIS 125 126Most SSL APIs, such as L<SSL_read(3)> and L<SSL_write(3)>, function as they do 127for TLS connections and do not have changed semantics, with some exceptions. The 128changes to the semantics of existing APIs are as follows: 129 130=over 4 131 132=item 133 134Since QUIC uses UDP, L<SSL_set_bio(3)>, L<SSL_set0_rbio(3)> and 135L<SSL_set0_wbio(3)> function as before, but must now receive a BIO with datagram 136semantics. There are broadly four options for applications to use as a network 137BIO: 138 139=over 4 140 141=item 142 143L<BIO_s_datagram(3)>, recommended for most applications, replaces 144L<BIO_s_socket(3)> and provides a UDP socket. 145 146=item 147 148L<BIO_s_dgram_pair(3)> provides BIO pair-like functionality but with datagram 149semantics, and is recommended for existing applications which use a BIO pair or 150memory BIO to manage libssl's communication with the network. 151 152=item 153 154L<BIO_s_dgram_mem(3)> provides a simple memory BIO-like interface but with 155datagram semantics. Unlike L<BIO_s_dgram_pair(3)>, it is unidirectional. 156 157=item 158 159An application may also choose to implement a custom BIO. The new 160L<BIO_sendmmsg(3)> and L<BIO_recvmmsg(3)> APIs must be supported. 161 162=back 163 164=item 165 166L<SSL_set_fd(3)>, L<SSL_set_rfd(3)> and L<SSL_set_wfd(3)> traditionally 167instantiate a L<BIO_s_socket(3)>. For QUIC, these functions instead instantiate 168a L<BIO_s_datagram(3)>. This is equivalent to instantiating a 169L<BIO_s_datagram(3)> and using L<SSL_set0_rbio(3)> and L<SSL_set0_wbio(3)>. 170 171=item 172 173Traditionally, whether the application-level I/O APIs (such as L<SSL_read(3)> 174and L<SSL_write(3)> operated in a blocking fashion was directly correlated with 175whether the underlying network socket was configured in a blocking fashion. This 176is no longer the case; applications must explicitly configure the desired 177application-level blocking mode using L<SSL_set_blocking_mode(3)>. See 178L<SSL_set_blocking_mode(3)> for details. 179 180=item 181 182Network-level I/O must always be performed in a nonblocking manner. The 183application can still enjoy blocking semantics for calls to application-level 184I/O functions such as L<SSL_read(3)> and L<SSL_write(3)>, but the underlying 185network BIO provided to QUIC (such as a L<BIO_s_datagram(3)>) must be configured 186in nonblocking mode. For application-level blocking functionality, see 187L<SSL_set_blocking_mode(3)>. 188 189=item 190 191L<BIO_new_ssl_connect(3)> has been changed to automatically use a 192L<BIO_s_datagram(3)> when used with QUIC, therefore applications which use this 193do not need to change the BIO they use. 194 195=item 196 197L<BIO_new_buffer_ssl_connect(3)> cannot be used with QUIC and applications must 198change to use L<BIO_new_ssl_connect(3)> instead. 199 200=item 201 202L<SSL_shutdown(3)> has significant changes in relation to how QUIC connections 203must be shut down. In particular, applications should be advised that the full 204RFC-conformant QUIC shutdown process may take an extended amount of time. This 205may not be suitable for short-lived processes which should exit immediately 206after their usage of a QUIC connection is completed. A rapid shutdown mode 207is available for such applications. For details, see L<SSL_shutdown(3)>. 208 209=item 210 211L<SSL_want(3)>, L<SSL_want_read(3)> and L<SSL_want_write(3)> no longer reflect 212the I/O state of the network BIO passed to the QUIC SSL object, but instead 213reflect the flow control state of the QUIC stream associated with the SSL 214object. 215 216When used in nonblocking mode, B<SSL_ERROR_WANT_READ> indicates that the 217receive part of a QUIC stream does not currently have any more data available to 218be read, and B<SSL_ERROR_WANT_WRITE> indicates that the stream's internal buffer 219is full. 220 221To determine if the QUIC implementation currently wishes to be informed of 222incoming network datagrams, use the new function L<SSL_net_read_desired(3)>; 223likewise, to determine if the QUIC implementation currently wishes to be 224informed when it is possible to transmit network datagrams, use the new function 225L<SSL_net_write_desired(3)>. Only applications which wish to manage their own event 226loops need to use these functions; see B<APPLICATION-DRIVEN EVENT LOOPS> for 227further discussion. 228 229=item 230 231The use of ALPN is mandatory when using QUIC. Attempts to connect without 232configuring ALPN will fail. For information on how to configure ALPN, see 233L<SSL_set_alpn_protos(3)>. 234 235=item 236 237Whether QUIC operates in a client or server mode is determined by the 238B<SSL_METHOD> used, rather than by calls to L<SSL_set_connect_state(3)> or 239L<SSL_set_accept_state(3)>. It is not necessary to call either of 240L<SSL_set_connect_state(3)> or L<SSL_set_accept_state(3)> before connecting, but 241if either of these are called, the function called must be congruent with the 242B<SSL_METHOD> being used. 243 244=item 245 246The L<SSL_set_min_proto_version(3)> and L<SSL_set_max_proto_version(3)> APIs are 247not used and the values passed to them are ignored, as OpenSSL QUIC currently 248always uses TLS 1.3. 249 250=item 251 252The following libssl functionality is not available when used with QUIC. 253 254=over 4 255 256=item 257 258Async functionality 259 260=item 261 262B<SSL_MODE_AUTO_RETRY> 263 264=item 265 266Record Padding and Fragmentation (L<SSL_set_block_padding(3)>, etc.) 267 268=item 269 270L<SSL_stateless(3)> support 271 272=item 273 274SRTP functionality 275 276=item 277 278TLSv1.3 Early Data 279 280=item 281 282TLS Next Protocol Negotiation cannot be used and is superseded by ALPN, which 283must be used instead. The use of ALPN is mandatory with QUIC. 284 285=item 286 287Post-Handshake Client Authentication is not available as QUIC prohibits its use. 288 289=item 290 291QUIC requires the use of TLSv1.3 or later, therefore functionality only relevant 292to older TLS versions is not available. 293 294=item 295 296Some cipher suites which are generally available for TLSv1.3 are not available 297for QUIC, such as B<TLS_AES_128_CCM_8_SHA256>. Your application may need to 298adjust the list of acceptable cipher suites it passes to libssl. 299 300=item 301 302CCM mode is not currently supported. 303 304=back 305 306The following libssl functionality is also not available when used with QUIC, 307but calls to the relevant functions are treated as no-ops: 308 309=over 4 310 311=item 312 313Readahead (L<SSL_set_read_ahead(3)>, etc.) 314 315=back 316 317=back 318 319=head1 CONSIDERATIONS FOR EXISTING APPLICATIONS 320 321Existing applications seeking to adopt QUIC should apply the following list to 322determine what changes they will need to make: 323 324=over 4 325 326=item 327 328A client application wishing to use QUIC must use L<OSSL_QUIC_client_method(3)> 329or L<OSSL_QUIC_client_thread_method(3)> as its SSL method. For more information 330on the differences between these two methods, see 331B<THREAD ASSISTED MODE>. 332 333=item 334 335A server application wishing to use QUIC must use L<OSSL_QUIC_server_method(3)>. 336The server can then accept new connections with L<SSL_accept_connection(3)>. 337 338=item 339 340Determine how to provide QUIC with network access. Determine which of the below 341apply for your application: 342 343=over 4 344 345=item 346 347Your application uses L<BIO_s_socket(3)> to construct a BIO which is passed to 348the SSL object to provide it with network access. 349 350Changes needed: Change your application to use L<BIO_s_datagram(3)> instead when 351using QUIC. The socket must be configured in nonblocking mode. You may or may 352not need to use L<SSL_set1_initial_peer_addr(3)> to set the initial peer 353address; see the B<QUIC-SPECIFIC APIS> section for details. 354 355=item 356 357Your application uses L<BIO_new_ssl_connect(3)> to 358construct a BIO which is passed to the SSL object to provide it with network 359access. 360 361Changes needed: No changes needed. Use of QUIC is detected automatically and a 362datagram socket is created instead of a normal TCP socket. 363 364=item 365 366Your application uses any other I/O strategy in this list but combines it with a 367L<BIO_f_buffer(3)>, for example using L<BIO_push(3)>. 368 369Changes needed: Disable the usage of L<BIO_f_buffer(3)> when using QUIC. Usage 370of such a buffer is incompatible with QUIC as QUIC requires datagram semantics 371in its interaction with the network. 372 373=item 374 375Your application uses a BIO pair to cause the SSL object to read and write 376network traffic to a memory buffer. Your application manages the transmission 377and reception of buffered data itself in a way unknown to libssl. 378 379Changes needed: Switch from using a conventional BIO pair to using 380L<BIO_s_dgram_pair(3)> instead, which has the necessary datagram semantics. You 381will need to modify your application to transmit and receive using a UDP socket 382and to use datagram semantics when interacting with the L<BIO_s_dgram_pair(3)> 383instance. 384 385=item 386 387Your application uses a custom BIO method to provide the SSL object with network 388access. 389 390Changes needed: The custom BIO must be re-architected to have datagram 391semantics. L<BIO_sendmmsg(3)> and L<BIO_recvmmsg(3)> must be implemented. These 392calls must operate in a nonblocking fashion. Optionally, implement the 393L<BIO_get_rpoll_descriptor(3)> and L<BIO_get_wpoll_descriptor(3)> methods if 394desired. Implementing these methods is required if blocking semantics at the SSL 395API level are desired. 396 397=back 398 399=item 400 401An application must explicitly configure whether it wishes to use the SSL APIs 402in blocking mode or not. Traditionally, an SSL object has automatically operated 403in blocking or nonblocking mode based on whether the underlying network BIO 404operates in blocking or nonblocking mode. QUIC requires the use of a 405nonblocking network BIO, therefore the blocking mode at the application level 406can be explicitly configured by the application using the new 407L<SSL_set_blocking_mode(3)> API. The default mode is blocking. If an application 408wishes to use the SSL object APIs at application level in a nonblocking manner, 409it must add a call to L<SSL_set_blocking_mode(3)> to disable blocking mode. 410 411=item 412 413If your client application does not choose to use thread assisted mode, it must 414ensure that it calls an I/O function on the SSL object (for example, 415L<SSL_read(3)> or L<SSL_write(3)>), or the new function L<SSL_handle_events(3)>, 416regularly. If the SSL object is used in blocking mode, an ongoing blocking call 417to an I/O function satisfies this requirement. This is required to ensure that 418timer events required by QUIC are handled in a timely fashion. 419 420Most applications will service the SSL object by calling L<SSL_read(3)> or 421L<SSL_write(3)> regularly. If an application does not do this, it should ensure 422that L<SSL_handle_events(3)> is called regularly. 423 424L<SSL_get_event_timeout(3)> can be used to determine when 425L<SSL_handle_events(3)> must next be called. 426 427If the SSL object is being used with an underlying network BIO which is pollable 428(such as L<BIO_s_datagram(3)>), the application can use 429L<SSL_get_rpoll_descriptor(3)>, L<SSL_get_wpoll_descriptor(3)> to obtain 430resources which can be used to determine when L<SSL_handle_events(3)> should be 431called due to network I/O. 432 433Client applications which use thread assisted mode do not need to be concerned 434with this requirement, as the QUIC implementation ensures timeout events 435are handled in a timely manner. See B<THREAD ASSISTED MODE> for details. 436 437=item 438 439Ensure that your usage of L<SSL_want(3)>, L<SSL_want_read(3)> and 440L<SSL_want_write(3)> reflects the API changes described in B<CHANGES TO EXISTING 441APIS>. In particular, you should use these APIs to determine the ability of a 442QUIC stream to receive or provide application data, not to to determine if 443network I/O is required. 444 445=item 446 447Evaluate your application's use of L<SSL_shutdown(3)> in light of the changes 448discussed in B<CHANGES TO EXISTING APIS>. Depending on whether your application 449wishes to prioritise RFC conformance or rapid shutdown, consider using the new 450L<SSL_shutdown_ex(3)> API instead. See B<QUIC-SPECIFIC APIS> for details. 451 452=back 453 454=head1 RECOMMENDED USAGE IN NEW APPLICATIONS 455 456The recommended usage in new applications varies depending on three independent 457design decisions: 458 459=over 4 460 461=item 462 463Whether the application will use blocking or nonblocking I/O at the application 464level (configured using L<SSL_set_blocking_mode(3)>). 465 466If the application does nonblocking I/O at the application level it can choose 467to manage its own polling and event loop; see B<APPLICATION-DRIVEN EVENT LOOPS>. 468 469=item 470 471Whether the application intends to give the QUIC implementation direct access to 472a network socket (e.g. via L<BIO_s_datagram(3)>) or whether it intends to buffer 473transmitted and received datagrams via a L<BIO_s_dgram_pair(3)> or custom BIO. 474 475The former is preferred where possible as it reduces latency to the network, 476which enables QUIC to achieve higher performance and more accurate connection 477round trip time (RTT) estimation. 478 479=item 480 481Whether thread assisted mode will be used (see B<THREAD ASSISTED MODE>). 482 483=back 484 485Simple demos for QUIC usage under these various scenarios can be found at 486L<https://github.com/openssl/openssl/tree/master/doc/designs/ddd>. 487 488Applications which wish to implement QUIC-specific protocols should be aware of 489the APIs listed under B<QUIC-SPECIFIC APIS> which provide access to 490QUIC-specific functionality. For example, L<SSL_stream_conclude(3)> can be used 491to indicate the end of the sending part of a stream, and L<SSL_shutdown_ex(3)> 492can be used to provide a QUIC application error code when closing a connection. 493 494Regardless of the design decisions chosen above, it is recommended that new 495applications avoid use of the default stream mode and use the multi-stream API 496by calling L<SSL_set_default_stream_mode(3)>; see the MODES OF OPERATION section 497for details. 498 499=head1 QUIC-SPECIFIC APIS 500 501This section details new APIs which are directly or indirectly related to QUIC. 502For details on the operation of each API, see the referenced man pages. 503 504The following SSL APIs are new but relevant to both QUIC and DTLS: 505 506=over 4 507 508=item L<SSL_get_event_timeout(3)> 509 510Determines when the QUIC implementation should next be woken up via a call to 511L<SSL_handle_events(3)> (or another I/O function such as L<SSL_read(3)> or 512L<SSL_write(3)>), if ever. 513 514This can also be used with DTLS and supersedes L<DTLSv1_get_timeout(3)> for new 515usage. 516 517=item L<SSL_handle_events(3)> 518 519This is a non-specific I/O operation which makes a best effort attempt to 520perform any pending I/O or timeout processing. It can be used to advance the 521QUIC state machine by processing incoming network traffic, generating outgoing 522network traffic and handling any expired timeout events. Most other I/O 523functions on an SSL object, such as L<SSL_read(3)> and L<SSL_write(3)>, 524implicitly perform event handling on the SSL object, so calling this function is 525only needed if no other I/O function is to be called. 526 527This can also be used with DTLS and supersedes L<DTLSv1_handle_timeout(3)> for 528new usage. 529 530=back 531 532The following SSL APIs are specific to QUIC: 533 534=over 4 535 536=item L<SSL_new_listener(3)> 537 538Creates a listener SSL object, which differs from an ordinary SSL object in that 539it is used to provide an abstraction for the acceptance of network connections 540in a protocol-agnostic manner. 541 542Currently, listener SSL objects are only supported for QUIC server usage or 543client-only usage. The listener interface may expand to support additional 544protocols in the future. 545 546=item L<SSL_new_listener_from(3)> 547 548Creates a listener SSL object which is subordinate to a QUIC domain SSL object 549I<ssl>. See L<SSL_new_domain(3)> and L<openssl-quic-concurrency(7)> for details 550on QUIC domain SSL objects. 551 552=item L<SSL_is_listener(3)> 553 554Returns 1 if and only if an SSL object is a listener SSL object. 555 556=item L<SSL_get0_listener(3)> 557 558Returns an SSL object pointer (potentially to the same object on which it is 559called) or NULL. 560 561=item L<SSL_listen(3)> 562 563Begin listening after a listener has been created. It is ordinarily not needed 564to call this because it will be called automatically on the first call to 565L<SSL_accept_connection(3)>. 566 567=item L<SSL_accept_connection(3)> 568 569Accepts a new incoming connection for a listner SSL object. A new SSL object 570representing the accepted connection is created and returned on success. If no 571incoming connection is available and the listener SSL object is configured in 572nonblocking mode, NULL is returned. 573 574=item L<SSL_get_accept_connection_queue_len(3)> 575 576Returns an informational value listing the number of connections waiting to be 577popped from the queue via calls to SSL_accept_connection(). 578 579=item L<SSL_new_from_listener(3)> 580 581Creates a client connection under a given listener SSL object. For QUIC, it is 582also possible to use SSL_new_from_listener() in conjunction with a listener 583which does accept incoming connections (i.e., which was not created using 584B<SSL_LISTENER_FLAG_NO_ACCEPT>), leading to a UDP network endpoint which has 585both incoming and outgoing connections. 586 587=item L<SSL_new_domain(3)> 588 589Creates a new QUIC event domain, represented as an SSL object. This is known as 590a QUIC domain SSL object. The concept of a QUIC event domain is discussed in 591detail in L<openssl-quic-concurrency(7)>. 592 593=item L<SSL_is_domain(3)> 594 595Returns 1 if an SSL object is a QUIC domain SSL object. 596 597=item L<SSL_get0_domain(3)> 598 599SSL_get0_domain() obtains a pointer to the QUIC domain SSL object in an SSL 600object hierarchy (if any). 601 602=item L<SSL_set_blocking_mode(3)>, L<SSL_get_blocking_mode(3)> 603 604Configures whether blocking semantics are used at the application level. This 605determines whether calls to functions such as L<SSL_read(3)> and L<SSL_write(3)> 606will block. 607 608=item L<SSL_get_rpoll_descriptor(3)>, L<SSL_get_wpoll_descriptor(3)> 609 610These functions facilitate operation in nonblocking mode. 611 612When an SSL object is being used with an underlying network read BIO which 613supports polling, L<SSL_get_rpoll_descriptor(3)> outputs an OS resource which 614can be used to synchronise on network readability events which should result in 615a call to L<SSL_handle_events(3)>. L<SSL_get_wpoll_descriptor(3)> works in an 616analogous fashion for the underlying network write BIO. 617 618The poll descriptors provided by these functions should be used only when 619L<SSL_net_read_desired(3)> and L<SSL_net_write_desired(3)> return 1, 620respectively. 621 622=item L<SSL_net_read_desired(3)>, L<SSL_net_write_desired(3)> 623 624These functions facilitate operation in nonblocking mode and are used in 625conjunction with L<SSL_get_rpoll_descriptor(3)> and 626L<SSL_get_wpoll_descriptor(3)> respectively. They determine whether the 627respective poll descriptor is currently relevant for the purposes of polling. 628 629=item L<SSL_set1_initial_peer_addr(3)> 630 631This function can be used to set the initial peer address for an outgoing QUIC 632connection. This function must be used in the general case when creating an 633outgoing QUIC connection; however, the correct initial peer address can be 634autodetected in some cases. See L<SSL_set1_initial_peer_addr(3)> for details. 635 636=item L<SSL_shutdown_ex(3)> 637 638This augments L<SSL_shutdown(3)> by allowing an application error code to be 639specified. It also allows an application to decide how quickly it wants a 640shutdown to be performed, potentially by trading off strict RFC compliance. 641 642=item L<SSL_stream_conclude(3)> 643 644This allows an application to indicate the normal end of the sending part of a 645QUIC stream. This corresponds to the FIN flag in the QUIC RFC. The receiving 646part of a stream remains usable. 647 648=item L<SSL_stream_reset(3)> 649 650This allows an application to indicate the non-normal termination of the sending 651part of a stream. This corresponds to the RESET_STREAM frame in the QUIC RFC. 652 653=item L<SSL_get_stream_write_state(3)> and L<SSL_get_stream_read_state(3)> 654 655This allows an application to determine the current stream states for the 656sending and receiving parts of a stream respectively. 657 658=item L<SSL_get_stream_write_error_code(3)> and L<SSL_get_stream_read_error_code(3)> 659 660This allows an application to determine the application error code which was 661signalled by a peer which has performed a non-normal stream termination of the 662respective sending or receiving part of a stream, if any. 663 664=item L<SSL_get_conn_close_info(3)> 665 666This allows an application to determine the error code which was signalled when 667the local or remote endpoint terminated the QUIC connection. 668 669=item L<SSL_get0_connection(3)> 670 671Gets the QUIC connection SSL object from a QUIC stream SSL object. 672 673=item L<SSL_is_connection(3)> 674 675Returns 1 if an SSL object is not a QUIC stream SSL object. 676 677=item L<SSL_get_stream_type(3)> 678 679Provides information on the kind of QUIC stream which is attached 680to the SSL object. 681 682=item L<SSL_get_stream_id(3)> 683 684Returns the QUIC stream ID which the QUIC protocol has associated with a QUIC 685stream. 686 687=item L<SSL_new_stream(3)> 688 689Creates a new QUIC stream SSL object representing a new, locally-initiated QUIC 690stream. 691 692=item L<SSL_accept_stream(3)> 693 694Potentially yields a new QUIC stream SSL object representing a new 695remotely-initiated QUIC stream, blocking until one is available if the 696connection is configured to do so. 697 698=item L<SSL_get_accept_stream_queue_len(3)> 699 700Provides information on the number of pending remotely-initiated streams. 701 702=item L<SSL_set_incoming_stream_policy(3)> 703 704Configures how incoming, remotely-initiated streams are handled. The incoming 705stream policy can be used to automatically reject streams created by the peer, 706or allow them to be handled using L<SSL_accept_stream(3)>. 707 708=item L<SSL_set_default_stream_mode(3)> 709 710Used to configure or disable default stream mode; see the MODES OF OPERATION 711section for details. 712 713=back 714 715The following BIO APIs are not specific to QUIC but have been added to 716facilitate QUIC-specific requirements and are closely associated with its use: 717 718=over 4 719 720=item L<BIO_s_dgram_pair(3)> 721 722This is a new BIO method which is similar to a conventional BIO pair but 723provides datagram semantics. 724 725=item L<BIO_get_rpoll_descriptor(3)>, L<BIO_get_wpoll_descriptor(3)> 726 727This is a new BIO API which allows a BIO to expose a poll descriptor. This API 728is used to implement the corresponding SSL APIs L<SSL_get_rpoll_descriptor(3)> 729and L<SSL_get_wpoll_descriptor(3)>. 730 731=item L<BIO_sendmmsg(3)>, L<BIO_recvmmsg(3)> 732 733This is a new BIO API which can be implemented by BIOs which implement datagram 734semantics. It is implemented by L<BIO_s_datagram(3)> and L<BIO_s_dgram_pair(3)>. 735It is used by the QUIC implementation to send and receive UDP datagrams. 736 737=item L<BIO_dgram_set_no_trunc(3)>, L<BIO_dgram_get_no_trunc(3)> 738 739By default, L<BIO_s_dgram_pair(3)> has semantics comparable to those of Berkeley 740sockets being used with datagram semantics. This allows an alternative mode 741to be enabled in which datagrams will not be silently truncated if they are 742too large. 743 744=item L<BIO_dgram_set_caps(3)>, L<BIO_dgram_get_caps(3)> 745 746These functions are used to allow the user of one end of a 747L<BIO_s_dgram_pair(3)> to indicate its capabilities to the other end of a 748L<BIO_s_dgram_pair(3)>. In particular, this allows an application to inform the 749QUIC implementation of whether it is prepared to handle local and/or peer 750addresses in transmitted datagrams and to provide the applicable information in 751received datagrams. 752 753=item L<BIO_dgram_get_local_addr_cap(3)>, L<BIO_dgram_set_local_addr_enable(3)>, 754L<BIO_dgram_get_local_addr_enable(3)> 755 756Local addressing support refers to the ability of a BIO with datagram semantics 757to allow a source address to be specified on transmission and to report the 758destination address on reception. These functions can be used to determine if a 759BIO can support local addressing and to enable local addressing support if it 760can. 761 762=item L<BIO_err_is_non_fatal(3)> 763 764This is used to determine if an error while calling L<BIO_sendmmsg(3)> or 765L<BIO_recvmmsg(3)> is ephemeral in nature, such as "would block" errors. 766 767=back 768 769=head1 THREAD ASSISTED MODE 770 771The optional thread assisted mode for clients can be used with 772L<OSSL_QUIC_client_thread_method(3)>. In this mode, a background thread is 773created automatically. The OpenSSL QUIC implementation then takes responsibility 774for ensuring that timeout events are handled on a timely basis even if no SSL 775I/O function such as L<SSL_read(3)> or L<SSL_write(3)> is called by the 776application for a long time. 777 778All necessary locking is handled automatically internally, but the thread safety 779guarantees for the public SSL API are unchanged. Therefore, an application must 780still do its own locking if it wishes to make concurrent use of the public SSL 781APIs. 782 783Because this method relies on threads, it is not available on platforms where 784threading support is not available or not supported by OpenSSL. However, it 785does provide the simplest mode of usage for an application. 786 787The implementation may or may not use a common thread or thread pool to service 788multiple SSL objects in the same B<SSL_CTX>. 789 790=head1 APPLICATION-DRIVEN EVENT LOOPS 791 792OpenSSL's QUIC implementation is designed to facilitate applications which wish 793to use the SSL APIs in a blocking fashion, but is also designed to facilitate 794applications which wish to use the SSL APIs in a nonblocking fashion and manage 795their own event loops and polling directly. This is useful when it is desirable 796to host OpenSSL's QUIC implementation on top of an application's existing 797nonblocking I/O infrastructure. 798 799This is supported via the concept of poll descriptors; see 800L<BIO_get_rpoll_descriptor(3)> for details. Broadly, a B<BIO_POLL_DESCRIPTOR> is 801a structure which expresses some kind of OS resource which can be used to 802synchronise on I/O events. The QUIC implementation provides a 803B<BIO_POLL_DESCRIPTOR> based on the poll descriptor provided by the underlying 804network BIO. This is typically an OS socket handle, though custom BIOs could 805choose to implement their own custom poll descriptor format. 806 807Broadly, an application which wishes to manage its own event loop should 808interact with the SSL object as follows: 809 810=over 4 811 812=item 813 814It should provide read and write BIOs with nonblocking datagram semantics to 815the SSL object using L<SSL_set0_rbio(3)> and L<SSL_set0_wbio(3)>. This could be 816a BIO abstracting a network socket such as L<BIO_s_datagram(3)>, or a BIO 817abstracting some kind of memory buffer such as L<BIO_s_dgram_pair(3)>. Use of a 818custom BIO is also possible. 819 820=item 821 822It should configure the SSL object into nonblocking mode by calling 823L<SSL_set_blocking_mode(3)>. 824 825=item 826 827It should configure the SSL object as desired, set an initial peer as needed 828using L<SSL_set1_initial_peer_addr(3)>, and trigger the connection process by 829calling L<SSL_connect(3)>. 830 831=item 832 833If the network read and write BIOs provided were pollable (for example, 834a L<BIO_s_datagram(3)>, or a custom BIO which implements 835L<BIO_get_rpoll_descriptor(3)> and L<BIO_get_wpoll_descriptor(3)>), it should 836perform the following steps repeatedly: 837 838=over 4 839 840=item 841 842The application should call L<SSL_get_rpoll_descriptor(3)> and 843L<SSL_get_wpoll_descriptor(3)> to identify OS resources which can be used for 844synchronisation. 845 846=item 847 848It should call L<SSL_net_read_desired(3)> and L<SSL_net_write_desired(3)> to determine 849whether the QUIC implementation is currently interested in readability and 850writability events on the underlying network BIO which was provided, and call 851L<SSL_get_event_timeout(3)> to determine if any timeout event will become 852applicable in the future. 853 854=item 855 856It should wait until one of the following events occurs: 857 858=over 4 859 860=item 861 862The poll descriptor returned by L<SSL_get_rpoll_descriptor(3)> becomes readable 863(if L<SSL_net_read_desired(3)> returned 1); 864 865=item 866 867The poll descriptor returned by L<SSL_get_wpoll_descriptor(3)> becomes writable 868(if L<SSL_net_write_desired(3)> returned 1); 869 870=item 871 872The timeout returned by L<SSL_get_event_timeout(3)> (if any) expires. 873 874=back 875 876Once any of these events occurs, L<SSL_handle_events(3)> should be called. 877 878=back 879 880=item 881 882If the network read and write BIOs provided were not pollable (for example, in 883the case of L<BIO_s_dgram_pair(3)>), the application is responsible for managing 884and synchronising network I/O. It should call L<SSL_handle_events(3)> after it 885writes data to a L<BIO_s_dgram_pair(3)> or otherwise takes action so that the 886QUIC implementation can read new datagrams via a call to L<BIO_recvmmsg(3)> on 887the underlying network BIO. The QUIC implementation may output datagrams via a 888call to L<BIO_sendmmsg(3)> and the application is responsible for ensuring these 889are transmitted. 890 891The application must call L<SSL_get_event_timeout(3)> after every call to 892L<SSL_handle_events(3)> (or another I/O function on the SSL object), and ensure 893that a call to L<SSL_handle_events(3)> is performed after the specified timeout 894(if any). 895 896=back 897 898=head1 SEE ALSO 899 900L<SSL_handle_events(3)>, L<SSL_get_event_timeout(3)>, 901L<SSL_net_read_desired(3)>, L<SSL_net_write_desired(3)>, 902L<SSL_get_rpoll_descriptor(3)>, L<SSL_get_wpoll_descriptor(3)>, 903L<SSL_set_blocking_mode(3)>, L<SSL_shutdown_ex(3)>, 904L<SSL_set1_initial_peer_addr(3)>, L<SSL_stream_conclude(3)>, 905L<SSL_stream_reset(3)>, L<SSL_get_stream_read_state(3)>, 906L<SSL_get_stream_read_error_code(3)>, L<SSL_get_conn_close_info(3)>, 907L<SSL_get0_connection(3)>, L<SSL_get_stream_type(3)>, L<SSL_get_stream_id(3)>, 908L<SSL_new_stream(3)>, L<SSL_accept_stream(3)>, 909L<SSL_set_incoming_stream_policy(3)>, L<SSL_set_default_stream_mode(3)>, 910L<SSL_new_listener(3)>, L<SSL_new_listener_from(3)>, L<SSL_is_listener(3)>, 911L<SSL_get0_listener(3)>, L<SSL_listen(3)>, L<SSL_accept_connection(3)>, 912L<SSL_get_accept_connection_queue_len(3)>, L<SSL_new_domain(3)>, 913L<SSL_is_domain(3)>, L<SSL_get0_domain(3)> 914 915=head1 COPYRIGHT 916 917Copyright 2022-2025 The OpenSSL Project Authors. All Rights Reserved. 918 919Licensed under the Apache License 2.0 (the "License"). You may not use 920this file except in compliance with the License. You can obtain a copy 921in the file LICENSE in the source distribution or at 922L<https://www.openssl.org/source/license.html>. 923 924=cut 925