1*e71b7053SJung-uk Kim=pod 2*e71b7053SJung-uk Kim 3*e71b7053SJung-uk Kim=head1 NAME 4*e71b7053SJung-uk Kim 5*e71b7053SJung-uk KimSSL_set_bio, SSL_set0_rbio, SSL_set0_wbio - connect the SSL object with a BIO 6*e71b7053SJung-uk Kim 7*e71b7053SJung-uk Kim=head1 SYNOPSIS 8*e71b7053SJung-uk Kim 9*e71b7053SJung-uk Kim #include <openssl/ssl.h> 10*e71b7053SJung-uk Kim 11*e71b7053SJung-uk Kim void SSL_set_bio(SSL *ssl, BIO *rbio, BIO *wbio); 12*e71b7053SJung-uk Kim void SSL_set0_rbio(SSL *s, BIO *rbio); 13*e71b7053SJung-uk Kim void SSL_set0_wbio(SSL *s, BIO *wbio); 14*e71b7053SJung-uk Kim 15*e71b7053SJung-uk Kim=head1 DESCRIPTION 16*e71b7053SJung-uk Kim 17*e71b7053SJung-uk KimSSL_set0_rbio() connects the BIO B<rbio> for the read operations of the B<ssl> 18*e71b7053SJung-uk Kimobject. The SSL engine inherits the behaviour of B<rbio>. If the BIO is 19*e71b7053SJung-uk Kimnon-blocking then the B<ssl> object will also have non-blocking behaviour. This 20*e71b7053SJung-uk Kimfunction transfers ownership of B<rbio> to B<ssl>. It will be automatically 21*e71b7053SJung-uk Kimfreed using L<BIO_free_all(3)> when the B<ssl> is freed. On calling this 22*e71b7053SJung-uk Kimfunction, any existing B<rbio> that was previously set will also be freed via a 23*e71b7053SJung-uk Kimcall to L<BIO_free_all(3)> (this includes the case where the B<rbio> is set to 24*e71b7053SJung-uk Kimthe same value as previously). 25*e71b7053SJung-uk Kim 26*e71b7053SJung-uk KimSSL_set0_wbio() works in the same as SSL_set0_rbio() except that it connects 27*e71b7053SJung-uk Kimthe BIO B<wbio> for the write operations of the B<ssl> object. Note that if the 28*e71b7053SJung-uk Kimrbio and wbio are the same then SSL_set0_rbio() and SSL_set0_wbio() each take 29*e71b7053SJung-uk Kimownership of one reference. Therefore it may be necessary to increment the 30*e71b7053SJung-uk Kimnumber of references available using L<BIO_up_ref(3)> before calling the set0 31*e71b7053SJung-uk Kimfunctions. 32*e71b7053SJung-uk Kim 33*e71b7053SJung-uk KimSSL_set_bio() is similar to SSL_set0_rbio() and SSL_set0_wbio() except 34*e71b7053SJung-uk Kimthat it connects both the B<rbio> and the B<wbio> at the same time, and 35*e71b7053SJung-uk Kimtransfers the ownership of B<rbio> and B<wbio> to B<ssl> according to 36*e71b7053SJung-uk Kimthe following set of rules: 37*e71b7053SJung-uk Kim 38*e71b7053SJung-uk Kim=over 2 39*e71b7053SJung-uk Kim 40*e71b7053SJung-uk Kim=item * 41*e71b7053SJung-uk Kim 42*e71b7053SJung-uk KimIf neither the B<rbio> or B<wbio> have changed from their previous values 43*e71b7053SJung-uk Kimthen nothing is done. 44*e71b7053SJung-uk Kim 45*e71b7053SJung-uk Kim=item * 46*e71b7053SJung-uk Kim 47*e71b7053SJung-uk KimIf the B<rbio> and B<wbio> parameters are different and both are different 48*e71b7053SJung-uk Kimto their 49*e71b7053SJung-uk Kimpreviously set values then one reference is consumed for the rbio and one 50*e71b7053SJung-uk Kimreference is consumed for the wbio. 51*e71b7053SJung-uk Kim 52*e71b7053SJung-uk Kim=item * 53*e71b7053SJung-uk Kim 54*e71b7053SJung-uk KimIf the B<rbio> and B<wbio> parameters are the same and the B<rbio> is not 55*e71b7053SJung-uk Kimthe same as the previously set value then one reference is consumed. 56*e71b7053SJung-uk Kim 57*e71b7053SJung-uk Kim=item * 58*e71b7053SJung-uk Kim 59*e71b7053SJung-uk KimIf the B<rbio> and B<wbio> parameters are the same and the B<rbio> is the 60*e71b7053SJung-uk Kimsame as the previously set value, then no additional references are consumed. 61*e71b7053SJung-uk Kim 62*e71b7053SJung-uk Kim=item * 63*e71b7053SJung-uk Kim 64*e71b7053SJung-uk KimIf the B<rbio> and B<wbio> parameters are different and the B<rbio> is the 65*e71b7053SJung-uk Kimsame as the 66*e71b7053SJung-uk Kimpreviously set value then one reference is consumed for the B<wbio> and no 67*e71b7053SJung-uk Kimreferences are consumed for the B<rbio>. 68*e71b7053SJung-uk Kim 69*e71b7053SJung-uk Kim=item * 70*e71b7053SJung-uk Kim 71*e71b7053SJung-uk KimIf the B<rbio> and B<wbio> parameters are different and the B<wbio> is the 72*e71b7053SJung-uk Kimsame as the previously set value and the old B<rbio> and B<wbio> values 73*e71b7053SJung-uk Kimwere the same as each other then one reference is consumed for the B<rbio> 74*e71b7053SJung-uk Kimand no references are consumed for the B<wbio>. 75*e71b7053SJung-uk Kim 76*e71b7053SJung-uk Kim=item * 77*e71b7053SJung-uk Kim 78*e71b7053SJung-uk KimIf the B<rbio> and B<wbio> parameters are different and the B<wbio> 79*e71b7053SJung-uk Kimis the same as the 80*e71b7053SJung-uk Kimpreviously set value and the old B<rbio> and B<wbio> values were different 81*e71b7053SJung-uk Kimto each 82*e71b7053SJung-uk Kimother then one reference is consumed for the B<rbio> and one reference 83*e71b7053SJung-uk Kimis consumed 84*e71b7053SJung-uk Kimfor the B<wbio>. 85*e71b7053SJung-uk Kim 86*e71b7053SJung-uk Kim=back 87*e71b7053SJung-uk Kim 88*e71b7053SJung-uk KimBecause of this complexity, this function should be avoided; 89*e71b7053SJung-uk Kimuse SSL_set0_rbio() and SSL_set0_wbio() instead. 90*e71b7053SJung-uk Kim 91*e71b7053SJung-uk Kim=head1 RETURN VALUES 92*e71b7053SJung-uk Kim 93*e71b7053SJung-uk KimSSL_set_bio(), SSL_set_rbio() and SSL_set_wbio() cannot fail. 94*e71b7053SJung-uk Kim 95*e71b7053SJung-uk Kim=head1 SEE ALSO 96*e71b7053SJung-uk Kim 97*e71b7053SJung-uk KimL<SSL_get_rbio(3)>, 98*e71b7053SJung-uk KimL<SSL_connect(3)>, L<SSL_accept(3)>, 99*e71b7053SJung-uk KimL<SSL_shutdown(3)>, L<ssl(7)>, L<bio(7)> 100*e71b7053SJung-uk Kim 101*e71b7053SJung-uk Kim=head1 HISTORY 102*e71b7053SJung-uk Kim 103*e71b7053SJung-uk KimSSL_set0_rbio() and SSL_set0_wbio() were added in OpenSSL 1.1.0. 104*e71b7053SJung-uk Kim 105*e71b7053SJung-uk Kim=head1 COPYRIGHT 106*e71b7053SJung-uk Kim 107*e71b7053SJung-uk KimCopyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved. 108*e71b7053SJung-uk Kim 109*e71b7053SJung-uk KimLicensed under the OpenSSL license (the "License"). You may not use 110*e71b7053SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 111*e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at 112*e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>. 113*e71b7053SJung-uk Kim 114*e71b7053SJung-uk Kim=cut 115