Skip to content

Commit b237748

Browse files
authored
feat: support TLS --ciphers and --signature_algs (#280)
* feat: support TLS --ciphers and --signature_algs * chore: update changelog
1 parent be1ed6d commit b237748

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
## 0.4.32
44

5-
* QoE: Fix csv dump, represent `invalid_elapsed` as `""` instead of `-1`
5+
* QoE: Fix csv dump, represent `invalid_elapsed` as `""` instead of `-1`
6+
* TLS: support `--ciphers` and `--signature-algs`
67

78
## 0.4.31
89

src/emqtt_bench.erl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@
8484
"client certificate for authentication, if required by server"},
8585
{keyfile, undefined, "keyfile", string,
8686
"client private key for authentication, if required by server"},
87+
{ciphers, undefined, "ciphers", string,
88+
"Cipher suite for ssl/tls connection, comma separated list. e.g. TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256"},
89+
{signature_algs, undefined, "signature-algs", string,
90+
"Signature algorithm for tlsv1.3 connection only, comma separated list. e.g. ecdsa_secp384r1_sha384,ecdsa_secp256r1_sha256"},
8791
{quic, undefined, "quic", {string, "false"},
8892
"QUIC transport"},
8993
{ws, undefined, "ws", {boolean, false},
@@ -970,7 +974,12 @@ tcp_opts([_|Opts], Acc) ->
970974
ssl_opts(Opts) ->
971975
ssl_opts(Opts, init_ssl_opts()).
972976
ssl_opts([], Acc) ->
973-
[{ciphers, all_ssl_ciphers()} | Acc];
977+
case lists:keymember(ciphers, 1, Acc) of
978+
false ->
979+
[{ciphers, all_ssl_ciphers()} | Acc];
980+
_ ->
981+
Acc
982+
end;
974983
ssl_opts([{host, Host} | Opts], Acc) ->
975984
ssl_opts(Opts, [{server_name_indication, Host} | Acc]);
976985
ssl_opts([{keyfile, KeyFile} | Opts], Acc) ->
@@ -989,6 +998,12 @@ ssl_opts([{nst_dets_file, DetsFile}| Opts], Acc) ->
989998
ok = prepare_nst(DetsFile),
990999
io:format("enable session_tickets~n"),
9911000
ssl_opts(Opts, [{session_tickets, manual}|Acc]);
1001+
ssl_opts([{ciphers, Ciphers}| Opts], Acc) ->
1002+
CipherList = [ssl:str_to_suite(X) || X <- string:tokens(Ciphers, ",")],
1003+
ssl_opts(Opts, [{ciphers, CipherList} | Acc]);
1004+
ssl_opts([{signature_algs, Algs}| Opts], Acc) ->
1005+
AlgList = [list_to_existing_atom(X) || X <- string:tokens(Algs, ",")],
1006+
ssl_opts(Opts, [{signature_algs, AlgList} | Acc]);
9921007
ssl_opts([_|Opts], Acc) ->
9931008
ssl_opts(Opts, Acc).
9941009

0 commit comments

Comments
 (0)