Skip to content

Commit

Permalink
Support TLS 1.3
Browse files Browse the repository at this point in the history
Fixes SIPp#693.
  • Loading branch information
orgads committed Mar 2, 2024
1 parent e69be5c commit acfe71c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/sipp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ struct sipp_option options_table[] = {
{"tls_key", "Set the name for TLS Private Key file. Default is 'cakey.pem'", SIPP_OPTION_STRING, &tls_key_name, 1},
{"tls_ca", "Set the name for TLS CA file. If not specified, X509 verification is not activated.", SIPP_OPTION_STRING, &tls_ca_name, 1},
{"tls_crl", "Set the name for Certificate Revocation List file. If not specified, X509 CRL is not activated.", SIPP_OPTION_STRING, &tls_crl_name, 1},
{"tls_version", "Set the TLS protocol version to use (1.0, 1.1, 1.2) -- default is autonegotiate", SIPP_OPTION_FLOAT, &tls_version, 1},
{"tls_version", "Set the TLS protocol version to use (1.0, 1.1, 1.2, 1.3) -- default is autonegotiate", SIPP_OPTION_FLOAT, &tls_version, 1},
#else
{"tls_cert", NULL, SIPP_OPTION_NEED_SSL, NULL, 1},
{"tls_key", NULL, SIPP_OPTION_NEED_SSL, NULL, 1},
Expand Down
8 changes: 8 additions & 0 deletions src/sslsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ static SSL_CTX* instantiate_ssl_context(const char* context_name)
max_tls_version = min_tls_version = TLS1_1_VERSION;
} else if (tls_version == 1.2) {
max_tls_version = min_tls_version = TLS1_2_VERSION;
} else if (tls_version == 1.3) {
max_tls_version = min_tls_version = TLS1_3_VERSION;
} else {
ERROR("Unrecognized TLS version for [%s] context: %1.1f", context_name, tls_version);
return NULL;
Expand Down Expand Up @@ -268,6 +270,12 @@ static SSL_CTX* instantiate_ssl_context(const char* context_name)
} else {
ssl_ctx = SSL_CTX_new(TLSv1_2_server_method());
}
} else if (tls_version == 1.3) {
if (!strncmp(context_name, "client", 6)) {
ssl_ctx = SSL_CTX_new(TLSv1_3_client_method());
} else {
ssl_ctx = SSL_CTX_new(TLSv1_3_server_method());
}
} else {
ERROR("Unrecognized TLS version for [%s] context: %1.1f", context_name, tls_version);
ssl_ctx = NULL;
Expand Down

0 comments on commit acfe71c

Please sign in to comment.