Skip to content

Commit

Permalink
Set SSL server session id
Browse files Browse the repository at this point in the history
  • Loading branch information
x4m committed Dec 4, 2019
1 parent b98d34d commit 6705c04
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions third_party/machinarium/sources/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,27 @@ machine_tls_create_context(machine_tls_t* obj, int is_client) {
// mm_tls_error(io, 0, "SSL_CTX_set_cipher_list()");
goto error;
}
if (! is_client )
if (! is_client ) {
unsigned char sid[SSL_MAX_SSL_SESSION_ID_LENGTH];
if (!RAND_bytes(sid, sizeof(sid))) {
//mm_tls_error(io, 0, "failed to generate session id");

}
if (!SSL_CTX_set_session_id_context(ctx, sid, sizeof(sid))) {
//mm_tls_error(io, 0, "failed to set session id context");
goto error;
}


SSL_CTX_set_options(ctx, SSL_OP_CIPHER_SERVER_PREFERENCE);
}

tls->tls_ctx = ctx;

return 0;
error:
if (tls->tls_ctx)
SSL_CTX_free(tls->tls_ctx);
if (ctx)
SSL_CTX_free(ctx);
tls->tls_ctx = NULL;
return -1;
}
Expand Down

0 comments on commit 6705c04

Please sign in to comment.