SSL_set_default_stream_mode.pod 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. =pod
  2. =head1 NAME
  3. SSL_set_default_stream_mode,
  4. SSL_DEFAULT_STREAM_MODE_NONE, SSL_DEFAULT_STREAM_MODE_AUTO_BIDI,
  5. SSL_DEFAULT_STREAM_MODE_AUTO_UNI - manage the default stream for a QUIC
  6. connection
  7. =head1 SYNOPSIS
  8. #include <openssl/ssl.h>
  9. #define SSL_DEFAULT_STREAM_MODE_NONE
  10. #define SSL_DEFAULT_STREAM_MODE_AUTO_BIDI
  11. #define SSL_DEFAULT_STREAM_MODE_AUTO_UNI
  12. int SSL_set_default_stream_mode(SSL *conn, uint32_t mode);
  13. =head1 DESCRIPTION
  14. A QUIC connection SSL object may have a default stream attached to it. A default
  15. stream is a QUIC stream to which calls to L<SSL_read(3)> and L<SSL_write(3)>
  16. made on a QUIC connection SSL object are redirected. Default stream handling
  17. allows legacy applications to use QUIC similarly to a traditional TLS
  18. connection.
  19. When not disabled, a default stream is automatically created on an outgoing
  20. connection once L<SSL_read(3)> or L<SSL_write(3)> is called.
  21. A QUIC stream must be explicitly designated as client-initiated or
  22. server-initiated up front. This broadly corresponds to whether an application
  23. protocol involves the client transmitting first, or the server transmitting
  24. first. As such, if L<SSL_read(3)> is called first (before any call to
  25. L<SSL_write(3)>) after establishing a connection, OpenSSL will wait for the
  26. server to open the first server-initiated stream, and then bind this as the
  27. default stream. Conversely, if L<SSL_write(3)> is called before any call to
  28. L<SSL_read(3)>, OpenSSL assumes the client wishes to transmit first, creates a
  29. client-initiated stream, and binds this as the default stream.
  30. By default, the default stream created is bidirectional. If a unidirectional
  31. stream is desired, or if the application wishes to disable default stream
  32. functionality, SSL_set_default_stream_mode() (discussed below) can be used to
  33. accomplish this.
  34. When a QUIC connection SSL object has no default stream currently associated
  35. with it, for example because default stream functionality was disabled, calls to
  36. functions which require a stream on the QUIC connection SSL object (for example,
  37. L<SSL_read(3)> and L<SSL_write(3)>) will fail.
  38. It is recommended that new applications and applications which rely on multiple
  39. streams forego use of the default stream functionality, which is intended for
  40. legacy applications.
  41. SSL_set_default_stream_mode() can be used to configure or disable default stream
  42. handling. It can only be called on a QUIC connection SSL object prior to any
  43. default stream being created. If used, it is recommended to call it immediately
  44. after calling L<SSL_new(3)>, prior to initiating a connection. The argument
  45. I<mode> may be one of the following options:
  46. =over 4
  47. =item SSL_DEFAULT_STREAM_MODE_AUTO_BIDI
  48. This is the default setting. If L<SSL_write(3)> is called prior to any call to
  49. L<SSL_read(3)>, a bidirectional client-initiated stream is created and bound as
  50. the default stream. If L<SSL_read(3)> is called prior to any call to
  51. L<SSL_write(3)>, OpenSSL waits for an incoming stream from the peer (causing
  52. L<SSL_read(3)> to block if the connection is in blocking mode), and then binds
  53. that stream as the default stream. Note that this incoming stream may be either
  54. bidirectional or unidirectional; thus, this setting does not guarantee the
  55. presence of a bidirectional stream when L<SSL_read(3)> is called first. To
  56. determine the type of a stream after a call to L<SSL_read(3)>, use
  57. L<SSL_get_stream_type(3)>.
  58. =item SSL_DEFAULT_STREAM_MODE_AUTO_UNI
  59. In this mode, if L<SSL_write(3)> is called prior to any call to L<SSL_read(3)>,
  60. a unidirectional client-initiated stream is created and bound as the default
  61. stream. The behaviour is otherwise identical to that of
  62. B<SSL_DEFAULT_STREAM_MODE_AUTO_BIDI>. The behaviour when L<SSL_read(3)> is
  63. called prior to any call to L<SSL_write(3)> is unchanged.
  64. =item SSL_DEFAULT_STREAM_MODE_NONE
  65. Default stream creation is inhibited. This is the recommended mode of operation.
  66. L<SSL_read(3)> and L<SSL_write(3)> calls cannot be made on the QUIC connection
  67. SSL object directly. You must obtain streams using L<SSL_new_stream(3)> or
  68. L<SSL_accept_stream(3)> in order to communicate with the peer.
  69. =back
  70. A default stream will not be automatically created on a QUIC connection SSL
  71. object if the default stream mode is set to B<SSL_DEFAULT_STREAM_MODE_NONE>.
  72. L<SSL_set_incoming_stream_policy(3)> interacts significantly with the default
  73. stream functionality.
  74. =head1 RETURN VALUES
  75. SSL_set_default_stream_mode() returns 1 on success and 0 on failure.
  76. SSL_set_default_stream_mode() fails if it is called after a default stream has
  77. already been established.
  78. These functions fail if called on a QUIC stream SSL object or on a non-QUIC SSL
  79. object.
  80. =head1 SEE ALSO
  81. L<SSL_new_stream(3)>, L<SSL_accept_stream(3)>, L<SSL_free(3)>,
  82. L<SSL_set_incoming_stream_policy(3)>
  83. =head1 HISTORY
  84. These functions were added in OpenSSL 3.2.
  85. =head1 COPYRIGHT
  86. Copyright 2002-2023 The OpenSSL Project Authors. All Rights Reserved.
  87. Licensed under the Apache License 2.0 (the "License"). You may not use
  88. this file except in compliance with the License. You can obtain a copy
  89. in the file LICENSE in the source distribution or at
  90. L<https://www.openssl.org/source/license.html>.
  91. =cut