net.nim: destroyContext for destroying SSLContext
This commit is contained in:
parent
ba61a8d00a
commit
3ecf33fa6a
2 changed files with 8 additions and 1 deletions
|
|
@ -13,3 +13,4 @@ proc clientFunc(identityHint: string): tuple[identity: string, psk: string] =
|
||||||
let context = newContext(cipherList="PSK-AES256-CBC-SHA")
|
let context = newContext(cipherList="PSK-AES256-CBC-SHA")
|
||||||
context.clientGetPskFunc = clientFunc
|
context.clientGetPskFunc = clientFunc
|
||||||
context.wrapConnectedSocket(sock, handshakeAsClient)
|
context.wrapConnectedSocket(sock, handshakeAsClient)
|
||||||
|
context.destroyContext()
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,6 @@ when defined(ssl):
|
||||||
newCTX.loadCertificates(certFile, keyFile)
|
newCTX.loadCertificates(certFile, keyFile)
|
||||||
|
|
||||||
result = SSLContext(newCTX)
|
result = SSLContext(newCTX)
|
||||||
# this is never freed, but SSLContext can't be freed anyway yet
|
|
||||||
let extraInternal = new(SslContextExtraInternal)
|
let extraInternal = new(SslContextExtraInternal)
|
||||||
GC_ref(extraInternal)
|
GC_ref(extraInternal)
|
||||||
result.setExtraData(extraInternalIndex, cast[pointer](extraInternal))
|
result.setExtraData(extraInternalIndex, cast[pointer](extraInternal))
|
||||||
|
|
@ -275,6 +274,13 @@ when defined(ssl):
|
||||||
proc getExtraInternal(ctx: SSLContext): SslContextExtraInternal =
|
proc getExtraInternal(ctx: SSLContext): SslContextExtraInternal =
|
||||||
return cast[SslContextExtraInternal](ctx.getExtraData(extraInternalIndex))
|
return cast[SslContextExtraInternal](ctx.getExtraData(extraInternalIndex))
|
||||||
|
|
||||||
|
proc destroyContext*(ctx: SSLContext) =
|
||||||
|
## Free memory referenced by SSLContext.
|
||||||
|
let extraInternal = ctx.getExtraInternal()
|
||||||
|
if extraInternal != nil:
|
||||||
|
GC_unref(extraInternal)
|
||||||
|
SSLCTX(ctx).SSL_CTX_free()
|
||||||
|
|
||||||
proc `pskIdentityHint=`*(ctx: SSLContext, hint: string) =
|
proc `pskIdentityHint=`*(ctx: SSLContext, hint: string) =
|
||||||
## Sets the identity hint passed to server.
|
## Sets the identity hint passed to server.
|
||||||
##
|
##
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue