net.nim: support for TLS-PSK ciphersuites
This commit is contained in:
parent
3ebf27ddd2
commit
ba61a8d00a
4 changed files with 144 additions and 13 deletions
15
examples/ssl/pskclient.nim
Normal file
15
examples/ssl/pskclient.nim
Normal file
|
|
@ -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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue