Skip to content

Commit 0ec9f14

Browse files
dndxthibaultcha
authored andcommitted
readme: documented the newly added tcpsock:tlshandshake method and
mark `tcpsock:sslhandshake` as deprecated.
1 parent e0cf817 commit 0ec9f14

File tree

1 file changed

+51
-23
lines changed

1 file changed

+51
-23
lines changed

README.markdown

Lines changed: 51 additions & 23 deletions
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

@@ -2952,7 +2951,7 @@ lua_ssl_ciphers
29522951

29532952
**context:** *http, server, location*
29542953

2955-
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.
2954+
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.
29562955

29572956
The full list can be viewed using the “openssl ciphers” command.
29582957

@@ -2969,7 +2968,7 @@ lua_ssl_crl
29692968

29702969
**context:** *http, server, location*
29712970

2972-
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.
2971+
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.
29732972

29742973
This directive was first introduced in the `v0.9.11` release.
29752974

@@ -2984,7 +2983,7 @@ lua_ssl_protocols
29842983

29852984
**context:** *http, server, location*
29862985

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

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

@@ -3001,7 +3000,7 @@ lua_ssl_trusted_certificate
30013000

30023001
**context:** *http, server, location*
30033002

3004-
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.
3003+
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.
30053004

30063005
This directive was first introduced in the `v0.9.11` release.
30073006

@@ -3292,6 +3291,7 @@ Nginx API for Lua
32923291
* [ngx.socket.stream](#ngxsocketstream)
32933292
* [ngx.socket.tcp](#ngxsockettcp)
32943293
* [tcpsock:connect](#tcpsockconnect)
3294+
* [tcpsock:tlshandshake](#tcpsocktlshandshake)
32953295
* [tcpsock:sslhandshake](#tcpsocksslhandshake)
32963296
* [tcpsock:send](#tcpsocksend)
32973297
* [tcpsock:receive](#tcpsockreceive)
@@ -7229,6 +7229,7 @@ ngx.socket.tcp
72297229
Creates and returns a TCP or stream-oriented unix domain socket object (also known as one type of the "cosocket" objects). The following methods are supported on this object:
72307230

72317231
* [connect](#tcpsockconnect)
7232+
* [tlshandshake](#tcpsocktlshandshake)
72327233
* [sslhandshake](#tcpsocksslhandshake)
72337234
* [send](#tcpsocksend)
72347235
* [receive](#tcpsockreceive)
@@ -7388,49 +7389,76 @@ This method was first introduced in the `v0.5.0rc1` release.
73887389

73897390
[Back to TOC](#nginx-api-for-lua)
73907391

7391-
tcpsock:sslhandshake
7392+
tcpsock:tlshandshake
73927393
--------------------
73937394

7394-
**syntax:** *session, err = tcpsock:sslhandshake(reused_session?, server_name?, ssl_verify?, send_status_req?)*
7395+
**syntax:** *session, err = tcpsock:tlshandshake(options)*
73957396

73967397
**context:** *rewrite_by_lua*, access_by_lua*, content_by_lua*, ngx.timer.*, ssl_certificate_by_lua*, ssl_session_fetch_by_lua**
73977398

73987399
Does SSL/TLS handshake on the currently established connection.
73997400

7400-
The optional `reused_session` argument can take a former SSL
7401-
session userdata returned by a previous `sslhandshake`
7402-
call for exactly the same target. For short-lived connections, reusing SSL
7401+
An optional Lua table containing the following keys can be specified to this method as handshake options:
7402+
7403+
* `reused_session` take a former TLS
7404+
session cdata returned by a previous `tlshandshake`
7405+
call for exactly the same target. For short-lived connections, reusing TLS
74037406
sessions can usually speed up the handshake by one order by magnitude but it
74047407
is not so useful if the connection pool is enabled. This argument defaults to
7405-
`nil`. If this argument takes the boolean `false` value, no SSL session
7406-
userdata would return by this call and only a Lua boolean will be returned as
7407-
the first return value; otherwise the current SSL session will
7408+
`nil`. If this argument takes the boolean `false` value, no TLS session
7409+
cdata would return by this call and only a Lua boolean will be returned as
7410+
the first return value; otherwise the current TLS session will
74087411
always be returned as the first argument in case of successes.
7409-
7410-
The optional `server_name` argument is used to specify the server
7412+
* `server_name` is used to specify the server
74117413
name for the new TLS extension Server Name Indication (SNI). Use of SNI can
74127414
make different servers share the same IP address on the server side. Also,
7413-
when SSL verification is enabled, this `server_name` argument is
7415+
when TLS verification is enabled (`options.verify` is `true`), this `server_name` argument is
74147416
also used to validate the server name specified in the server certificate sent from
74157417
the remote.
7416-
7417-
The optional `ssl_verify` argument takes a Lua boolean value to
7418-
control whether to perform SSL verification. When set to `true`, the server
7418+
* `verify` takes a Lua boolean value to
7419+
control whether to perform TLS handshake verification. When set to `true`, the server
74197420
certificate will be verified according to the CA certificates specified by
74207421
the [lua_ssl_trusted_certificate](#lua_ssl_trusted_certificate) directive.
74217422
You may also need to adjust the [lua_ssl_verify_depth](#lua_ssl_verify_depth)
74227423
directive to control how deep we should follow along the certificate chain.
7423-
Also, when the `ssl_verify` argument is true and the
7424+
Also, when the `verify` argument is true and the
74247425
`server_name` argument is also specified, the latter will be used
74257426
to validate the server name in the server certificate.
7426-
7427-
The optional `send_status_req` argument takes a boolean that controls whether to send
7427+
* `ocsp_status_req` takes a Lua boolean value that controls whether to send
74287428
the OCSP status request in the SSL handshake request (which is for requesting OCSP stapling).
7429+
* `client_cert` specify a client certificate chain cdata object that will be used while handshaking with
7430+
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)
7431+
function provided by lua-resty-core. Note that specifying the `client_cert` option requires
7432+
corresponding `client_priv_key` be provided too. See below.
7433+
* `client_priv_key` specify a private key corresponds to the `client_cert` option above.
7434+
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)
7435+
function provided by lua-resty-core.
7436+
7437+
For code that does frequent calls to `tlshandshake`, the `options` table
7438+
can be safely shared across requests as a module level variable (even if the call yields).
74297439

74307440
For connections that have already done SSL/TLS handshake, this method returns
74317441
immediately.
74327442

7433-
This method was first introduced in the `v0.9.11` release.
7443+
This method was first introduced in the `v0.10.16` release.
7444+
7445+
[Back to TOC](#nginx-api-for-lua)
7446+
7447+
tcpsock:sslhandshake
7448+
--------------------
7449+
7450+
**syntax:** *session, err = tcpsock:sslhandshake(reused_session?, server_name?, verify?, ocsp_status_req?)*
7451+
7452+
**context:** *rewrite_by_lua*, access_by_lua*, content_by_lua*, ngx.timer.*, ssl_certificate_by_lua*, ssl_session_fetch_by_lua**
7453+
7454+
Does SSL/TLS handshake on the currently established connection.
7455+
7456+
**Note:** This function is **deprecated** and is just a helper that calls the newly added [tlshandshake](#tcpsocktlshandshake) function.
7457+
Newer code should use [tlshandshake](#tcpsocktlshandshake) directly instead.
7458+
7459+
For usage info and meaning of the arguments, refer to the options description in [tlshandshake](#tcpsocktlshandshake).
7460+
7461+
This method was first introduced in the `v0.9.11` release and is marked as deprecated in the `v0.10.16` release.
74347462

74357463
[Back to TOC](#nginx-api-for-lua)
74367464

0 commit comments

Comments
 (0)