Skip to content

Commit a6c4f3e

Browse files
committed
readme: documented the newly added tcpsock:tlshandshake method and
mark `tcpsock:sslhandshake` as deprecated.
1 parent 240103c commit a6c4f3e

File tree

1 file changed

+51
-23
lines changed

1 file changed

+51
-23
lines changed

README.markdown

+51-23
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,6 @@ TODO
927927
* add `ignore_resp_headers`, `ignore_resp_body`, and `ignore_resp` options to [ngx.location.capture](#ngxlocationcapture) and [ngx.location.capture_multi](#ngxlocationcapture_multi) methods, to allow micro performance tuning on the user side.
928928
* add automatic Lua code time slicing support by yielding and resuming the Lua VM actively via Lua's debug hooks.
929929
* add `stat` mode similar to [mod_lua](https://httpd.apache.org/docs/trunk/mod/mod_lua.html).
930-
* cosocket: add client SSL certificate support.
931930

932931
[Back to TOC](#table-of-contents)
933932

@@ -2948,7 +2947,7 @@ lua_ssl_ciphers
29482947

29492948
**context:** *http, server, location*
29502949

2951-
Specifies the enabled ciphers for requests to a SSL/TLS server in the [tcpsock:sslhandshake](#tcpsocksslhandshake) method. The ciphers are specified in the format understood by the OpenSSL library.
2950+
Specifies the enabled ciphers for requests to a SSL/TLS server in the [tcpsock:tlshandshake](#tcpsocktlshandshake) method. The ciphers are specified in the format understood by the OpenSSL library.
29522951

29532952
The full list can be viewed using the “openssl ciphers” command.
29542953

@@ -2965,7 +2964,7 @@ lua_ssl_crl
29652964

29662965
**context:** *http, server, location*
29672966

2968-
Specifies a file with revoked certificates (CRL) in the PEM format used to verify the certificate of the SSL/TLS server in the [tcpsock:sslhandshake](#tcpsocksslhandshake) method.
2967+
Specifies a file with revoked certificates (CRL) in the PEM format used to verify the certificate of the SSL/TLS server in the [tcpsock:tlshandshake](#tcpsocktlshandshake) method.
29692968

29702969
This directive was first introduced in the `v0.9.11` release.
29712970

@@ -2980,7 +2979,7 @@ lua_ssl_protocols
29802979

29812980
**context:** *http, server, location*
29822981

2983-
Enables the specified protocols for requests to a SSL/TLS server in the [tcpsock:sslhandshake](#tcpsocksslhandshake) method.
2982+
Enables the specified protocols for requests to a SSL/TLS server in the [tcpsock:tlshandshake](#tcpsocktlshandshake) method.
29842983

29852984
The support for the `TLSv1.3` parameter requires version `v0.10.12` *and* OpenSSL 1.1.1.
29862985

@@ -2997,7 +2996,7 @@ lua_ssl_trusted_certificate
29972996

29982997
**context:** *http, server, location*
29992998

3000-
Specifies a file path with trusted CA certificates in the PEM format used to verify the certificate of the SSL/TLS server in the [tcpsock:sslhandshake](#tcpsocksslhandshake) method.
2999+
Specifies a file path with trusted CA certificates in the PEM format used to verify the certificate of the SSL/TLS server in the [tcpsock:tlshandshake](#tcpsocktlshandshake) method.
30013000

30023001
This directive was first introduced in the `v0.9.11` release.
30033002

@@ -3289,6 +3288,7 @@ Nginx API for Lua
32893288
* [ngx.socket.tcp](#ngxsockettcp)
32903289
* [tcpsock:connect](#tcpsockconnect)
32913290
* [tcpsock:sslhandshake](#tcpsocksslhandshake)
3291+
* [tcpsock:tlshandshake](#tcpsocktlshandshake)
32923292
* [tcpsock:send](#tcpsocksend)
32933293
* [tcpsock:receive](#tcpsockreceive)
32943294
* [tcpsock:receiveany](#tcpsockreceiveany)
@@ -7188,6 +7188,7 @@ Creates and returns a TCP or stream-oriented unix domain socket object (also kno
71887188

71897189
* [connect](#tcpsockconnect)
71907190
* [sslhandshake](#tcpsocksslhandshake)
7191+
* [tlshandshake](#tcpsocktlshandshake)
71917192
* [send](#tcpsocksend)
71927193
* [receive](#tcpsockreceive)
71937194
* [close](#tcpsockclose)
@@ -7343,49 +7344,76 @@ This method was first introduced in the `v0.5.0rc1` release.
73437344

73447345
[Back to TOC](#nginx-api-for-lua)
73457346

7346-
tcpsock:sslhandshake
7347+
tcpsock:tlshandshake
73477348
--------------------
73487349

7349-
**syntax:** *session, err = tcpsock:sslhandshake(reused_session?, server_name?, ssl_verify?, send_status_req?)*
7350+
**syntax:** *session, err = tcpsock:tlshandshake(options)*
73507351

73517352
**context:** *rewrite_by_lua*, access_by_lua*, content_by_lua*, ngx.timer.*, ssl_certificate_by_lua*, ssl_session_fetch_by_lua**
73527353

73537354
Does SSL/TLS handshake on the currently established connection.
73547355

7355-
The optional `reused_session` argument can take a former SSL
7356-
session userdata returned by a previous `sslhandshake`
7357-
call for exactly the same target. For short-lived connections, reusing SSL
7356+
An optional Lua table containing the following keys can be specified to this method as handshake options:
7357+
7358+
* `reused_session` take a former TLS
7359+
session cdata returned by a previous `tlshandshake`
7360+
call for exactly the same target. For short-lived connections, reusing TLS
73587361
sessions can usually speed up the handshake by one order by magnitude but it
73597362
is not so useful if the connection pool is enabled. This argument defaults to
7360-
`nil`. If this argument takes the boolean `false` value, no SSL session
7361-
userdata would return by this call and only a Lua boolean will be returned as
7362-
the first return value; otherwise the current SSL session will
7363+
`nil`. If this argument takes the boolean `false` value, no TLS session
7364+
cdata would return by this call and only a Lua boolean will be returned as
7365+
the first return value; otherwise the current TLS session will
73637366
always be returned as the first argument in case of successes.
7364-
7365-
The optional `server_name` argument is used to specify the server
7367+
* `server_name` is used to specify the server
73667368
name for the new TLS extension Server Name Indication (SNI). Use of SNI can
73677369
make different servers share the same IP address on the server side. Also,
7368-
when SSL verification is enabled, this `server_name` argument is
7370+
when TLS verification is enabled (`options.verify` is `true`), this `server_name` argument is
73697371
also used to validate the server name specified in the server certificate sent from
73707372
the remote.
7371-
7372-
The optional `ssl_verify` argument takes a Lua boolean value to
7373-
control whether to perform SSL verification. When set to `true`, the server
7373+
* `verify` takes a Lua boolean value to
7374+
control whether to perform TLS handshake verification. When set to `true`, the server
73747375
certificate will be verified according to the CA certificates specified by
73757376
the [lua_ssl_trusted_certificate](#lua_ssl_trusted_certificate) directive.
73767377
You may also need to adjust the [lua_ssl_verify_depth](#lua_ssl_verify_depth)
73777378
directive to control how deep we should follow along the certificate chain.
7378-
Also, when the `ssl_verify` argument is true and the
7379+
Also, when the `verify` argument is true and the
73797380
`server_name` argument is also specified, the latter will be used
73807381
to validate the server name in the server certificate.
7381-
7382-
The optional `send_status_req` argument takes a boolean that controls whether to send
7382+
* `ocsp_status_req` takes a Lua boolean value that controls whether to send
73837383
the OCSP status request in the SSL handshake request (which is for requesting OCSP stapling).
7384+
* `client_cert` specify a client certificate chain cdata object that will be used while handshaking with
7385+
remote server. These objects can be created using [ngx.ssl.parse\_pem\_cert](https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/ssl.md#parse_pem_cert)
7386+
function provided by lua-resty-core. Note that specifying the `client_cert` option requires
7387+
corresponding `client_priv_key` be provided too. See below.
7388+
* `client_priv_key` specify a private key corresponds to the `client_cert` option above.
7389+
These objects can be created using [ngx.ssl.parse\_pem\_priv\_key](https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/ssl.md#parse_pem_priv_key)
7390+
function provided by lua-resty-core.
7391+
7392+
For code that does frequent calls to `tlshandshake`, the `options` table
7393+
can be safely shared across requests as a module level variable (even if the call yields).
73847394

73857395
For connections that have already done SSL/TLS handshake, this method returns
73867396
immediately.
73877397

7388-
This method was first introduced in the `v0.9.11` release.
7398+
This method was first introduced in the `v0.10.16` release.
7399+
7400+
[Back to TOC](#nginx-api-for-lua)
7401+
7402+
tcpsock:sslhandshake
7403+
--------------------
7404+
7405+
**syntax:** *session, err = tcpsock:sslhandshake(reused_session?, server_name?, verify?, ocsp_status_req?)*
7406+
7407+
**context:** *rewrite_by_lua*, access_by_lua*, content_by_lua*, ngx.timer.*, ssl_certificate_by_lua*, ssl_session_fetch_by_lua**
7408+
7409+
Does SSL/TLS handshake on the currently established connection.
7410+
7411+
**Note:** This function is **deprecated** and is just a helper that calls the newly added [tlshandshake](#tcpsocktlshandshake) function.
7412+
Newer code should use [tlshandshake](#tcpsocktlshandshake) directly instead.
7413+
7414+
For usage info and meaning of the arguments, refer to the options description in [tlshandshake](#tcpsocktlshandshake).
7415+
7416+
This method was first introduced in the `v0.9.11` release and is marked as deprecated in the `v0.10.16` release.
73897417

73907418
[Back to TOC](#nginx-api-for-lua)
73917419

0 commit comments

Comments
 (0)