diff options
| author | bentley <> | 2014-10-12 09:33:04 +0000 |
|---|---|---|
| committer | bentley <> | 2014-10-12 09:33:04 +0000 |
| commit | 82b7f378b6907ab315a6e50322d2a0a8794a0aa9 (patch) | |
| tree | a5087bf8d016a6041c2b6822fbecfd8f6c5e70b1 /src/lib/libssl/doc/SSL_read.3 | |
| parent | 0a63f0cf49369e1926567ab62e04e3355cedf0cd (diff) | |
| download | openbsd-82b7f378b6907ab315a6e50322d2a0a8794a0aa9.tar.gz openbsd-82b7f378b6907ab315a6e50322d2a0a8794a0aa9.tar.bz2 openbsd-82b7f378b6907ab315a6e50322d2a0a8794a0aa9.zip | |
Convert libssl manpages from pod to mdoc(7).
libcrypto has not been started yet.
ok schwarze@ miod@
Diffstat (limited to 'src/lib/libssl/doc/SSL_read.3')
| -rw-r--r-- | src/lib/libssl/doc/SSL_read.3 | 190 |
1 files changed, 190 insertions, 0 deletions
diff --git a/src/lib/libssl/doc/SSL_read.3 b/src/lib/libssl/doc/SSL_read.3 new file mode 100644 index 0000000000..aed39c300f --- /dev/null +++ b/src/lib/libssl/doc/SSL_read.3 | |||
| @@ -0,0 +1,190 @@ | |||
| 1 | .Dd $Mdocdate: October 12 2014 $ | ||
| 2 | .Dt SSL_READ 3 | ||
| 3 | .Os | ||
| 4 | .Sh NAME | ||
| 5 | .Nm SSL_read | ||
| 6 | .Nd read bytes from a TLS/SSL connection. | ||
| 7 | .Sh SYNOPSIS | ||
| 8 | .In openssl/ssl.h | ||
| 9 | .Ft int | ||
| 10 | .Fn SSL_read "SSL *ssl" "void *buf" "int num" | ||
| 11 | .Sh DESCRIPTION | ||
| 12 | .Fn SSL_read | ||
| 13 | tries to read | ||
| 14 | .Fa num | ||
| 15 | bytes from the specified | ||
| 16 | .Fa ssl | ||
| 17 | into the buffer | ||
| 18 | .Fa buf . | ||
| 19 | .Sh NOTES | ||
| 20 | If necessary, | ||
| 21 | .Fn SSL_read | ||
| 22 | will negotiate a TLS/SSL session, if not already explicitly performed by | ||
| 23 | .Xr SSL_connect 3 | ||
| 24 | or | ||
| 25 | .Xr SSL_accept 3 . | ||
| 26 | If the peer requests a re-negotiation, | ||
| 27 | it will be performed transparently during the | ||
| 28 | .Fn SSL_read | ||
| 29 | operation. | ||
| 30 | The behaviour of | ||
| 31 | .Fn SSL_read | ||
| 32 | depends on the underlying | ||
| 33 | .Vt BIO . | ||
| 34 | .Pp | ||
| 35 | For the transparent negotiation to succeed, the | ||
| 36 | .Fa ssl | ||
| 37 | must have been initialized to client or server mode. | ||
| 38 | This is being done by calling | ||
| 39 | .Xr SSL_set_connect_state 3 | ||
| 40 | or | ||
| 41 | .Xr SSL_set_accept_state 3 | ||
| 42 | before the first call to | ||
| 43 | .Fn SSL_read | ||
| 44 | or | ||
| 45 | .Xr SSL_write 3 . | ||
| 46 | .Pp | ||
| 47 | .Fn SSL_read | ||
| 48 | works based on the SSL/TLS records. | ||
| 49 | The data are received in records (with a maximum record size of 16kB for | ||
| 50 | SSLv3/TLSv1). | ||
| 51 | Only after a record has been completely received can it be processed | ||
| 52 | (decrypted and checked for integrity). | ||
| 53 | Therefore data not retrieved at the last call of | ||
| 54 | .Fn SSL_read | ||
| 55 | can still be buffered inside the SSL layer and will be retrieved on the next | ||
| 56 | call to | ||
| 57 | .Fn SSL_read . | ||
| 58 | If | ||
| 59 | .Fa num | ||
| 60 | is higher than the number of bytes buffered, | ||
| 61 | .Fn SSL_read | ||
| 62 | will return with the bytes buffered. | ||
| 63 | If no more bytes are in the buffer, | ||
| 64 | .Fn SSL_read | ||
| 65 | will trigger the processing of the next record. | ||
| 66 | Only when the record has been received and processed completely will | ||
| 67 | .Fn SSL_read | ||
| 68 | return reporting success. | ||
| 69 | At most the contents of the record will be returned. | ||
| 70 | As the size of an SSL/TLS record may exceed the maximum packet size of the | ||
| 71 | underlying transport (e.g., TCP), it may be necessary to read several packets | ||
| 72 | from the transport layer before the record is complete and | ||
| 73 | .Fn SSL_read | ||
| 74 | can succeed. | ||
| 75 | .Pp | ||
| 76 | If the underlying | ||
| 77 | .Vt BIO | ||
| 78 | is | ||
| 79 | .Em blocking , | ||
| 80 | .Fn SSL_read | ||
| 81 | will only return once the read operation has been finished or an error | ||
| 82 | has occurred, except when a renegotiation take place, in which case a | ||
| 83 | .Dv SSL_ERROR_WANT_READ | ||
| 84 | may occur. | ||
| 85 | This behavior can be controlled with the | ||
| 86 | .Dv SSL_MODE_AUTO_RETRY | ||
| 87 | flag of the | ||
| 88 | .Xr SSL_CTX_set_mode 3 | ||
| 89 | call. | ||
| 90 | .Pp | ||
| 91 | If the underlying | ||
| 92 | .Vt BIO | ||
| 93 | is | ||
| 94 | .Em non-blocking , | ||
| 95 | .Fn SSL_read | ||
| 96 | will also return when the underlying | ||
| 97 | .Vt BIO | ||
| 98 | could not satisfy the needs of | ||
| 99 | .Fn SSL_read | ||
| 100 | to continue the operation. | ||
| 101 | In this case a call to | ||
| 102 | .Xr SSL_get_error 3 | ||
| 103 | with the return value of | ||
| 104 | .Fn SSL_read | ||
| 105 | will yield | ||
| 106 | .Dv SSL_ERROR_WANT_READ | ||
| 107 | or | ||
| 108 | .Dv SSL_ERROR_WANT_WRITE . | ||
| 109 | As at any time a re-negotiation is possible, a call to | ||
| 110 | .Fn SSL_read | ||
| 111 | can also cause write operations! | ||
| 112 | The calling process then must repeat the call after taking appropriate action | ||
| 113 | to satisfy the needs of | ||
| 114 | .Fn SSL_read . | ||
| 115 | The action depends on the underlying | ||
| 116 | .Vt BIO . | ||
| 117 | When using a non-blocking socket, nothing is to be done, but | ||
| 118 | .Xr select 2 | ||
| 119 | can be used to check for the required condition. | ||
| 120 | When using a buffering | ||
| 121 | .Vt BIO , | ||
| 122 | like a | ||
| 123 | .Vt BIO | ||
| 124 | pair, data must be written into or retrieved out of the | ||
| 125 | .Vt BIO | ||
| 126 | before being able to continue. | ||
| 127 | .Pp | ||
| 128 | .Xr SSL_pending 3 | ||
| 129 | can be used to find out whether there are buffered bytes available for | ||
| 130 | immediate retrieval. | ||
| 131 | In this case | ||
| 132 | .Fn SSL_read | ||
| 133 | can be called without blocking or actually receiving new data from the | ||
| 134 | underlying socket. | ||
| 135 | .Sh WARNING | ||
| 136 | When an | ||
| 137 | .Fn SSL_read | ||
| 138 | operation has to be repeated because of | ||
| 139 | .Dv SSL_ERROR_WANT_READ | ||
| 140 | or | ||
| 141 | .Dv SSL_ERROR_WANT_WRITE , | ||
| 142 | it must be repeated with the same arguments. | ||
| 143 | .Sh RETURN VALUES | ||
| 144 | The following return values can occur: | ||
| 145 | .Bl -tag -width Ds | ||
| 146 | .It >0 | ||
| 147 | The read operation was successful; the return value is the number of bytes | ||
| 148 | actually read from the TLS/SSL connection. | ||
| 149 | .It 0 | ||
| 150 | The read operation was not successful. | ||
| 151 | The reason may either be a clean shutdown due to a | ||
| 152 | .Dq close notify | ||
| 153 | alert sent by the peer (in which case the | ||
| 154 | .Dv SSL_RECEIVED_SHUTDOWN | ||
| 155 | flag in the ssl shutdown state is set (see | ||
| 156 | .Xr SSL_shutdown 3 | ||
| 157 | and | ||
| 158 | .Xr SSL_set_shutdown 3 ) . | ||
| 159 | It is also possible that the peer simply shut down the underlying transport and | ||
| 160 | the shutdown is incomplete. | ||
| 161 | Call | ||
| 162 | .Fn SSL_get_error | ||
| 163 | with the return value to find out whether an error occurred or the connection | ||
| 164 | was shut down cleanly | ||
| 165 | .Pq Dv SSL_ERROR_ZERO_RETURN . | ||
| 166 | .Pp | ||
| 167 | SSLv2 (deprecated) does not support a shutdown alert protocol, so it can only | ||
| 168 | be detected whether the underlying connection was closed. | ||
| 169 | It cannot be checked whether the closure was initiated by the peer or by | ||
| 170 | something else. | ||
| 171 | .It <0 | ||
| 172 | The read operation was not successful, because either an error occurred or | ||
| 173 | action must be taken by the calling process. | ||
| 174 | Call | ||
| 175 | .Fn SSL_get_error | ||
| 176 | with the return value to find out the reason. | ||
| 177 | .El | ||
| 178 | .Sh SEE ALSO | ||
| 179 | .Xr bio 3 , | ||
| 180 | .Xr ssl 3 , | ||
| 181 | .Xr SSL_accept 3 , | ||
| 182 | .Xr SSL_connect 3 , | ||
| 183 | .Xr SSL_CTX_new 3 , | ||
| 184 | .Xr SSL_CTX_set_mode 3 , | ||
| 185 | .Xr SSL_get_error 3 , | ||
| 186 | .Xr SSL_pending 3 , | ||
| 187 | .Xr SSL_set_connect_state 3 , | ||
| 188 | .Xr SSL_set_shutdown 3 , | ||
| 189 | .Xr SSL_shutdown 3 , | ||
| 190 | .Xr SSL_write 3 | ||
