Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cipher support #107

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ SSL_CTX *ssl_init() {
return ctx;
}

status ssl_set_cipher_list(SSL_CTX *ctx, char *ciphers) {
if (SSL_CTX_set_cipher_list(ctx, ciphers) == 0) {
return ERROR;
}
return OK;
}

status ssl_connect(connection *c, char *host) {
int r;
SSL_set_fd(c->ssl, c->fd);
Expand Down
1 change: 1 addition & 0 deletions src/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

SSL_CTX *ssl_init();

status ssl_set_cipher_list(SSL_CTX *, char *);
status ssl_connect(connection *, char *);
status ssl_close(connection *);
status ssl_read(connection *, size_t *);
Expand Down
17 changes: 16 additions & 1 deletion src/wrk.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ static struct config {
bool record_all_responses;
char *host;
char *script;
char *ciphers;
SSL_CTX *ctx;
} cfg;

Expand Down Expand Up @@ -57,6 +58,7 @@ static void usage() {
" -t, --threads <N> Number of threads to use \n"
" \n"
" -s, --script <S> Load Lua script file \n"
" -z, --ciphers <S> Specify SSL/TLS ciphers \n"
" -H, --header <H> Add header to request \n"
" -L --latency Print latency statistics \n"
" -U --u_latency Print uncorrected latency statistics\n"
Expand Down Expand Up @@ -94,6 +96,15 @@ int main(int argc, char **argv) {
ERR_print_errors_fp(stderr);
exit(1);
}

if (NULL != cfg.ciphers) {
if (ssl_set_cipher_list(cfg.ctx, cfg.ciphers) == ERROR) {
fprintf(stderr, "unable to set SSL ciphers: %s\n", cfg.ciphers);
ERR_print_errors_fp(stderr);
exit(1);
}
}

sock.connect = ssl_connect;
sock.close = ssl_close;
sock.read = ssl_read;
Expand Down Expand Up @@ -696,6 +707,7 @@ static struct option longopts[] = {
{ "duration", required_argument, NULL, 'd' },
{ "threads", required_argument, NULL, 't' },
{ "script", required_argument, NULL, 's' },
{ "ciphers", required_argument, NULL, 's' },
{ "header", required_argument, NULL, 'H' },
{ "latency", no_argument, NULL, 'L' },
{ "u_latency", no_argument, NULL, 'U' },
Expand All @@ -718,7 +730,7 @@ static int parse_args(struct config *cfg, char **url, struct http_parser_url *pa
cfg->rate = 0;
cfg->record_all_responses = true;

while ((c = getopt_long(argc, argv, "t:c:d:s:H:T:R:LUBrv?", longopts, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "t:c:d:s:z:H:T:R:LUBrv?", longopts, NULL)) != -1) {
switch (c) {
case 't':
if (scan_metric(optarg, &cfg->threads)) return -1;
Expand All @@ -732,6 +744,9 @@ static int parse_args(struct config *cfg, char **url, struct http_parser_url *pa
case 's':
cfg->script = optarg;
break;
case 'z':
cfg->ciphers = optarg;
break;
case 'H':
*header++ = optarg;
break;
Expand Down