diff options
Diffstat (limited to 'examples/ssl/pskclient.nim')
-rw-r--r-- | examples/ssl/pskclient.nim | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/examples/ssl/pskclient.nim b/examples/ssl/pskclient.nim new file mode 100644 index 000000000..7c93bbb61 --- /dev/null +++ b/examples/ssl/pskclient.nim @@ -0,0 +1,15 @@ +# Create connection encrypted using preshared key (TLS-PSK). +import net + +static: assert defined(ssl) + +let sock = newSocket() +sock.connect("localhost", Port(8800)) + +proc clientFunc(identityHint: string): tuple[identity: string, psk: string] = + echo "identity hint ", identityHint.repr + return ("foo", "psk-of-foo") + +let context = newContext(cipherList="PSK-AES256-CBC-SHA") +context.clientGetPskFunc = clientFunc +context.wrapConnectedSocket(sock, handshakeAsClient) |