⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ssl_read.pod

📁 开源的ssl算法openssl,版本0.9.8H
💻 POD
字号:
=pod=head1 NAMESSL_read - read bytes from a TLS/SSL connection.=head1 SYNOPSIS #include <openssl/ssl.h> int SSL_read(SSL *ssl, void *buf, int num);=head1 DESCRIPTIONSSL_read() tries to read B<num> bytes from the specified B<ssl> into thebuffer B<buf>.=head1 NOTESIf necessary, SSL_read() will negotiate a TLS/SSL session, ifnot already explicitly performed by L<SSL_connect(3)|SSL_connect(3)> orL<SSL_accept(3)|SSL_accept(3)>. If thepeer requests a re-negotiation, it will be performed transparently duringthe SSL_read() operation. The behaviour of SSL_read() depends on theunderlying BIO. For the transparent negotiation to succeed, the B<ssl> must have beeninitialized to client or server mode. This is being done by callingL<SSL_set_connect_state(3)|SSL_set_connect_state(3)> or SSL_set_accept_state()before the first call to an SSL_read() or L<SSL_write(3)|SSL_write(3)>function.SSL_read() works based on the SSL/TLS records. The data are received inrecords (with a maximum record size of 16kB for SSLv3/TLSv1). Only when arecord has been completely received, it can be processed (decryption andcheck of integrity). Therefore data that was not retrieved at the lastcall of SSL_read() can still be buffered inside the SSL layer and will beretrieved on the next call to SSL_read(). If B<num> is higher than thenumber of bytes buffered, SSL_read() will return with the bytes buffered.If no more bytes are in the buffer, SSL_read() will trigger the processingof the next record. Only when the record has been received and processedcompletely, SSL_read() will return reporting success. At most the contentsof the record will be returned. As the size of an SSL/TLS record may exceedthe maximum packet size of the underlying transport (e.g. TCP), it maybe necessary to read several packets from the transport layer before therecord is complete and SSL_read() can succeed.If the underlying BIO is B<blocking>, SSL_read() will only return, once theread operation has been finished or an error occurred, except when arenegotiation take place, in which case a SSL_ERROR_WANT_READ may occur. This behaviour can be controlled with the SSL_MODE_AUTO_RETRY flag of theL<SSL_CTX_set_mode(3)|SSL_CTX_set_mode(3)> call.If the underlying BIO is B<non-blocking>, SSL_read() will also returnwhen the underlying BIO could not satisfy the needs of SSL_read()to continue the operation. In this case a call toL<SSL_get_error(3)|SSL_get_error(3)> with thereturn value of SSL_read() will yield B<SSL_ERROR_WANT_READ> orB<SSL_ERROR_WANT_WRITE>. As at any time a re-negotiation is possible, acall to SSL_read() can also cause write operations! The calling processthen must repeat the call after taking appropriate action to satisfy theneeds of SSL_read(). The action depends on the underlying BIO. When using anon-blocking socket, nothing is to be done, but select() can be used to checkfor the required condition. When using a buffering BIO, like a BIO pair, datamust be written into or retrieved out of the BIO before being able to continue.=head1 WARNINGWhen an SSL_read() operation has to be repeated because ofB<SSL_ERROR_WANT_READ> or B<SSL_ERROR_WANT_WRITE>, it must be repeatedwith the same arguments.=head1 RETURN VALUESThe following return values can occur:=over 4=item E<gt>0The read operation was successful; the return value is the number ofbytes actually read from the TLS/SSL connection.=item 0The read operation was not successful. The reason may either be a cleanshutdown due to a "close notify" alert sent by the peer (in which casethe SSL_RECEIVED_SHUTDOWN flag in the ssl shutdown state is set(see L<SSL_shutdown(3)|SSL_shutdown(3)>,L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>). It is also possible, thatthe peer simply shut down the underlying transport and the shutdown isincomplete. Call SSL_get_error() with the return value B<ret> to find out,whether an error occurred or the connection was shut down cleanly(SSL_ERROR_ZERO_RETURN).SSLv2 (deprecated) does not support a shutdown alert protocol, so it canonly be detected, whether the underlying connection was closed. It cannotbe checked, whether the closure was initiated by the peer or by somethingelse.=item E<lt>0The read operation was not successful, because either an error occurredor action must be taken by the calling process. Call SSL_get_error() with thereturn value B<ret> to find out the reason.=back=head1 SEE ALSOL<SSL_get_error(3)|SSL_get_error(3)>, L<SSL_write(3)|SSL_write(3)>,L<SSL_CTX_set_mode(3)|SSL_CTX_set_mode(3)>, L<SSL_CTX_new(3)|SSL_CTX_new(3)>,L<SSL_connect(3)|SSL_connect(3)>, L<SSL_accept(3)|SSL_accept(3)>L<SSL_set_connect_state(3)|SSL_set_connect_state(3)>,L<SSL_shutdown(3)|SSL_shutdown(3)>, L<SSL_set_shutdown(3)|SSL_set_shutdown(3)>,L<ssl(3)|ssl(3)>, L<bio(3)|bio(3)>=cut

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -