mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
Add SSL_CTX_set_session_id_context (#15233)
* Added SSL_CTX_set_session_id_context() * Added basic nimdoc * Raise an error if sessionIdContext is longer than the maximum length * Update nimdocs
This commit is contained in:
@@ -825,6 +825,22 @@ when defineSsl:
|
||||
else:
|
||||
result = getPeerCertificates(socket.sslHandle)
|
||||
|
||||
proc `sessionIdContext=`*(ctx: SslContext, sidCtx: string) =
|
||||
## Sets the session id context in which a session can be reused.
|
||||
## Used for permitting clients to reuse a session id instead of
|
||||
## doing a new handshake.
|
||||
##
|
||||
## TLS clients might attempt to resume a session using the session id context,
|
||||
## thus it must be set if verifyMode is set to CVerifyPeer or CVerifyPeerUseEnvVars,
|
||||
## otherwise the connection will fail and SslError will be raised if resumption occurs.
|
||||
##
|
||||
## - Only useful if set server-side.
|
||||
## - Should be unique per-application to prevent clients from malfunctioning.
|
||||
## - sidCtx must be at most 32 characters in length.
|
||||
if sidCtx.len > 32:
|
||||
raiseSSLError("sessionIdContext must be shorter than 32 characters")
|
||||
SSL_CTX_set_session_id_context(ctx.context, sidCtx, sidCtx.len)
|
||||
|
||||
proc getSocketError*(socket: Socket): OSErrorCode =
|
||||
## Checks ``osLastError`` for a valid error. If it has been reset it uses
|
||||
## the last error stored in the socket object.
|
||||
|
||||
@@ -436,6 +436,7 @@ proc SSL_new*(context: SslCtx): SslPtr{.cdecl, dynlib: DLLSSLName, importc.}
|
||||
proc SSL_free*(ssl: SslPtr){.cdecl, dynlib: DLLSSLName, importc.}
|
||||
proc SSL_get_SSL_CTX*(ssl: SslPtr): SslCtx {.cdecl, dynlib: DLLSSLName, importc.}
|
||||
proc SSL_set_SSL_CTX*(ssl: SslPtr, ctx: SslCtx): SslCtx {.cdecl, dynlib: DLLSSLName, importc.}
|
||||
proc SSL_CTX_set_session_id_context*(context: SslCtx, sid_ctx: string, sid_ctx_len: int){.cdecl, dynlib: DLLSSLName, importc.}
|
||||
proc SSL_get0_verified_chain*(ssl: SslPtr): PSTACK {.cdecl, dynlib: DLLSSLName,
|
||||
importc.}
|
||||
proc SSL_CTX_new*(meth: PSSL_METHOD): SslCtx{.cdecl,
|
||||
|
||||
Reference in New Issue
Block a user