Skip to content

Commit 2de5ebb

Browse files
authored
Merge pull request #431 from sshanks-kx/ssl
improved docs for .z.e .z.w .z.W
2 parents cc896e5 + 5e45615 commit 2de5ebb

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

docs/ref/dotz.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,44 @@ The number of physical cores.
209209

210210
## `.z.e` (TLS connection status)
211211

212-
TLS details used with a connection handle. Returns an empty dictionary if the connection is not TLS enabled. E.g. where `h` is a connection handle.
212+
TLS details used with the current connection handle.
213+
Returns an empty dictionary if the connection is not TLS enabled.
214+
215+
Displays information on the following
216+
217+
* `CIPHER` is the name of cipher used for the connection
218+
* `PROTOCOL` is the name of the protocol used for the connection, for example `` `TLSv1.2 ``
219+
* `CERT` is the X509 certificate the peer presented. It is not present if the peer certificate was not provided.
220+
221+
For example, the following connects to a server, then runs `.z.e` on the server to gain information on the TLS connection handle used by the client. Therefore `CERT` is the client certificate (peer of the server).
222+
If [`SSL_VERIFY_CLIENT`](../kb/ssl.md#ssl_verify_client) is not enabled on the server, the client certificate is not requested by the server, and therefore would not be displayed.
213223

214224
```q
225+
q)h:hopen `:tcps://localhost:5000
215226
q)h".z.e"
216227
CIPHER | `AES128-GCM-SHA256
217228
PROTOCOL| `TLSv1.2
218229
CERT | `SUBJECT`ISSUER`SERIALNUMBER`NOTVALIDBEFORE`NOTVALIDAFTER`VERIFIED`VERIFYERROR!("/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=myname.com";"/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=examplebrooklyn.com";,"1";"Jul 6 10:08:57 2021 GMT";"May 15 10:08:57 2031 GMT";1b;0)
219230
```
220231

232+
The following shows the client sending a message to the server, which in turn sends `.z.e` to the client (using the current connection handle [`.z.w`](#zw-handle)), displaying the server certificate used by the client connection.
233+
```q
234+
q)h:hopen `:tcps://localhost:5000
235+
q)h".z.w\".z.e\""
236+
CIPHER | `TLS_AES_256_GCM_SHA384
237+
PROTOCOL | `TLSv1.3
238+
CERT | `SUBJECT`ISSUER`SERIALNUMBER`NOTVALIDBEFORE`NOTVALIDAFTER`VERIFIED`VERIFYERROR!("/C=US/ST=CA/L=Somewhere/O=Someone/CN=Foobar";"/C=US/ST=CA/L=Somewhere/O=Someone/CN=FoobarCA";"1399A138267E9EB69529717C24FDA451932AE3FD";"Jan 12 17:20:10 2026 GMT";"Jan 12 17:20:10 2027 GMT";1b;0)
239+
```
240+
241+
When called from code executing a client callback function due to a client request, it can be used to gain TLS information on the client connection.
242+
For example, the following implements the connection open callback ([`.z.po`](#zpo-open)) to print TLS information each time a client connects.
243+
244+
```q
245+
.z.po:{show"SSL server connection info:";show .z.e;show"SSL client connection info:";show .z.w".z.e"}
246+
```
247+
248+
`.z.w".z.e"` is used to run .z.e on the client (via a [sync request](../basics/ipc.md#sync-request-get) over the connection provided by [`.z.w`](#zw-handle))
249+
221250
Since V3.4 2016.05.16. `CERT` details of `VERIFIED`,`VERIFYERROR` available since 4.1t 2024.02.07.
222251

223252
:fontawesome-solid-hand-point-right:
@@ -950,7 +979,9 @@ q)m[1;1]:0
950979
## `.z.W` (handles)
951980

952981
Dictionary of IPC handles with the number of bytes waiting in their output queues.
982+
[`.z.H`](#zh-active-sockets) is a lower cost method if the size of the output queue is not required.
953983

984+
The following demonstrates a client connection which has created [async requests](../basics/ipc.md#async-message-set), causing pending data in its connection output queue.
954985
```q
955986
q)h:hopen ...
956987
q)h
@@ -988,14 +1019,15 @@ q)neg[h]"11+1111111";(-38!h)`m
9881019

9891020
## `.z.w` (handle)
9901021

991-
Connection handle; 0 for current session console.
1022+
The current connection handle. When called within the current session console, it will return 0i.
9921023

9931024
```q
9941025
q).z.w
9951026
0i
9961027
```
9971028

998-
!!! warning "Inside a `.z.p`* callback it returns the handle of the client session, not the current session."
1029+
When called from code executing a client callback function due to a client request, for example [`.z.pg`](#zpg-get), it returns the handle of the client connection.
1030+
This can be used for performing tasks such as sending a [sync/async request](../basics/ipc.md#send-messages) to the client or recording the handle upon which a request should be later fulfilled.
9991031

10001032
:fontawesome-solid-hand-point-right:
10011033
[`.z.H`](#zh-active-sockets) (active sockets), [`.z.W`](#zw-handles) (handles), [`-38!`](../basics/internal.md#-38x-socket-table) (socket table)

0 commit comments

Comments
 (0)