SSL_set_bio.pod 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. =pod
  2. =head1 NAME
  3. SSL_set_bio, SSL_set0_rbio, SSL_set0_wbio - connect the SSL object with a BIO
  4. =head1 SYNOPSIS
  5. #include <openssl/ssl.h>
  6. void SSL_set_bio(SSL *ssl, BIO *rbio, BIO *wbio);
  7. void SSL_set0_rbio(SSL *s, BIO *rbio);
  8. void SSL_set0_wbio(SSL *s, BIO *wbio);
  9. =head1 DESCRIPTION
  10. SSL_set0_rbio() connects the BIO B<rbio> for the read operations of the B<ssl>
  11. object. The SSL engine inherits the behaviour of B<rbio>. If the BIO is
  12. nonblocking then the B<ssl> object will also have nonblocking behaviour. This
  13. function transfers ownership of B<rbio> to B<ssl>. It will be automatically
  14. freed using L<BIO_free_all(3)> when the B<ssl> is freed. On calling this
  15. function, any existing B<rbio> that was previously set will also be freed via a
  16. call to L<BIO_free_all(3)> (this includes the case where the B<rbio> is set to
  17. the same value as previously).
  18. If using a custom BIO, B<rbio> must implement either
  19. L<BIO_meth_set_read_ex(3)> or L<BIO_meth_set_read(3)>.
  20. SSL_set0_wbio() works in the same as SSL_set0_rbio() except that it connects
  21. the BIO B<wbio> for the write operations of the B<ssl> object. Note that if the
  22. rbio and wbio are the same then SSL_set0_rbio() and SSL_set0_wbio() each take
  23. ownership of one reference. Therefore, it may be necessary to increment the
  24. number of references available using L<BIO_up_ref(3)> before calling the set0
  25. functions.
  26. If using a custom BIO, B<wbio> must implement
  27. L<BIO_meth_set_write_ex(3)> or L<BIO_meth_set_write(3)>. It additionally must
  28. implement L<BIO_flush(3)> using B<BIO_CTRL_FLUSH> and L<BIO_meth_set_ctrl(3)>.
  29. If flushing is unnecessary with B<wbio>, L<BIO_flush(3)> should return one and
  30. do nothing.
  31. SSL_set_bio() is similar to SSL_set0_rbio() and SSL_set0_wbio() except
  32. that it connects both the B<rbio> and the B<wbio> at the same time, and
  33. transfers the ownership of B<rbio> and B<wbio> to B<ssl> according to
  34. the following set of rules:
  35. =over 2
  36. =item *
  37. If neither the B<rbio> or B<wbio> have changed from their previous values
  38. then nothing is done.
  39. =item *
  40. If the B<rbio> and B<wbio> parameters are different and both are different
  41. to their
  42. previously set values then one reference is consumed for the rbio and one
  43. reference is consumed for the wbio.
  44. =item *
  45. If the B<rbio> and B<wbio> parameters are the same and the B<rbio> is not
  46. the same as the previously set value then one reference is consumed.
  47. =item *
  48. If the B<rbio> and B<wbio> parameters are the same and the B<rbio> is the
  49. same as the previously set value, then no additional references are consumed.
  50. =item *
  51. If the B<rbio> and B<wbio> parameters are different and the B<rbio> is the
  52. same as the
  53. previously set value then one reference is consumed for the B<wbio> and no
  54. references are consumed for the B<rbio>.
  55. =item *
  56. If the B<rbio> and B<wbio> parameters are different and the B<wbio> is the
  57. same as the previously set value and the old B<rbio> and B<wbio> values
  58. were the same as each other then one reference is consumed for the B<rbio>
  59. and no references are consumed for the B<wbio>.
  60. =item *
  61. If the B<rbio> and B<wbio> parameters are different and the B<wbio>
  62. is the same as the
  63. previously set value and the old B<rbio> and B<wbio> values were different
  64. to each other, then one reference is consumed for the B<rbio> and one
  65. reference is consumed for the B<wbio>.
  66. =back
  67. Because of this complexity, this function should be avoided;
  68. use SSL_set0_rbio() and SSL_set0_wbio() instead.
  69. Where a new BIO is set on a QUIC connection SSL object, blocking mode will be
  70. disabled on that SSL object if the BIO cannot support blocking mode. If another
  71. BIO is subsequently set on the SSL object which can support blocking mode,
  72. blocking mode will not be automatically re-enabled. For more information, see
  73. L<SSL_set_blocking_mode(3)>.
  74. =head1 RETURN VALUES
  75. SSL_set_bio(), SSL_set0_rbio() and SSL_set0_wbio() cannot fail.
  76. =head1 SEE ALSO
  77. L<SSL_get_rbio(3)>,
  78. L<SSL_connect(3)>, L<SSL_accept(3)>,
  79. L<SSL_shutdown(3)>, L<ssl(7)>, L<bio(7)>
  80. =head1 HISTORY
  81. SSL_set0_rbio() and SSL_set0_wbio() were added in OpenSSL 1.1.0.
  82. =head1 COPYRIGHT
  83. Copyright 2000-2023 The OpenSSL Project Authors. All Rights Reserved.
  84. Licensed under the Apache License 2.0 (the "License"). You may not use
  85. this file except in compliance with the License. You can obtain a copy
  86. in the file LICENSE in the source distribution or at
  87. L<https://www.openssl.org/source/license.html>.
  88. =cut