Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
set session ID when TLS resume is enabled
  • Loading branch information
wfurt authored and github-actions committed Sep 13, 2022
commit caf65d5ac99303a204c8255e3a53444bfa64fe64
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ const EVP_CIPHER* EVP_chacha20_poly1305(void);
REQUIRED_FUNCTION(SSL_CTX_set_quiet_shutdown) \
FALLBACK_FUNCTION(SSL_CTX_set_options) \
FALLBACK_FUNCTION(SSL_CTX_set_security_level) \
REQUIRED_FUNCTION(SSL_CTX_set_session_id_context) \
REQUIRED_FUNCTION(SSL_CTX_set_verify) \
REQUIRED_FUNCTION(SSL_CTX_use_certificate) \
REQUIRED_FUNCTION(SSL_CTX_use_PrivateKey) \
Expand Down Expand Up @@ -965,6 +966,7 @@ FOR_ALL_OPENSSL_FUNCTIONS
#define SSL_CTX_set_options SSL_CTX_set_options_ptr
#define SSL_CTX_set_quiet_shutdown SSL_CTX_set_quiet_shutdown_ptr
#define SSL_CTX_set_security_level SSL_CTX_set_security_level_ptr
#define SSL_CTX_set_session_id_context SSL_CTX_set_session_id_context_ptr
#define SSL_CTX_set_verify SSL_CTX_set_verify_ptr
#define SSL_CTX_use_certificate SSL_CTX_use_certificate_ptr
#define SSL_CTX_use_PrivateKey SSL_CTX_use_PrivateKey_ptr
Expand Down
12 changes: 10 additions & 2 deletions src/native/libs/System.Security.Cryptography.Native/pal_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <assert.h>
#include <string.h>
#include <stdbool.h>
#include <sys/random.h>

c_static_assert(PAL_SSL_ERROR_NONE == SSL_ERROR_NONE);
c_static_assert(PAL_SSL_ERROR_SSL == SSL_ERROR_SSL);
Expand Down Expand Up @@ -678,9 +679,16 @@ int CryptoNative_SslCtxSetCaching(SSL_CTX* ctx, int mode, int cacheSize, SslCtxN
{
SSL_CTX_set_options(ctx, SSL_OP_NO_TICKET);
}
else if (cacheSize >= 0)
else
{
SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SESS_CACHE_SIZE, (long)cacheSize, NULL);
unsigned char id[SSL_MAX_SID_CTX_LENGTH];
getrandom(id, sizeof(id), GRND_RANDOM);
SSL_CTX_set_session_id_context(ctx, id, sizeof(id));

if (cacheSize >= 0)
{
SSL_CTX_ctrl(ctx, SSL_CTRL_SET_SESS_CACHE_SIZE, (long)cacheSize, NULL);
}
}

if (newSessionCb != NULL)
Expand Down