From 6c1477b8f688f038dd5b5d30a48963135f19fb90 Mon Sep 17 00:00:00 2001 From: Ivan Dyachkov Date: Tue, 26 Nov 2024 13:23:01 +0100 Subject: [PATCH] feat: add cacertfile option --- README.md | 11 ++++++++--- src/emqtt_bench.erl | 8 ++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b1ff7fe..520f9cc 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Usage: emqtt_bench conn [--help ] [-d ] [-h []] [-n []] [--load-qst ] [-Q []] [-i []] [-u ] [-P ] [-k []] [-C []] - [-x []] [-S []] + [-x []] [-S []] [--cacertfile ] [--certfile ] [--keyfile ] [--quic []] [--ifaddr ] [--prefix ] [-s []] @@ -78,6 +78,7 @@ Usage: emqtt_bench conn [--help ] [-d ] [-h []] (seconds) [default: 0] -S, --ssl ssl socoket for connecting to server [default: false] + --cacertfile CA certificate for server verification --certfile client certificate for authentication, if required by server --keyfile client private key for authentication, if @@ -123,7 +124,8 @@ $ ./emqtt_bench sub --help Usage: emqtt_bench sub [--help ] [-d ] [-h []] [-p []] [-V []] [-c []] [-n []] [-i []] [-t ] [--payload-hdrs []] [-q []] [-Q []] [-u ] [-P ] [-k []] [-C []] [-x []] - [-S []] [--certfile ] [--keyfile ] [--ws []] [--quic []] + [-S []] [--cacertfile ] [--certfile ] [--keyfile ] + [--ws []] [--quic []] [--load-qst ] [--ifaddr ] [--prefix ] [-s []] [-l ] [--num-retry-connect []] [-R []] [--force-major-gc-interval []] [--log_to []] @@ -152,6 +154,7 @@ Usage: emqtt_bench sub [--help ] [-d ] [-h []] [-p []] [ -C, --clean clean start [default: true] -x, --session-expiry Set 'Session-Expiry' for persistent sessions (seconds) [default: 0] -S, --ssl ssl socoket for connecting to server [default: false] + --cacertfile CA certificate for server verification --certfile client certificate for authentication, if required by server --keyfile client private key for authentication, if required by server --ws websocket transport [default: false] @@ -195,7 +198,8 @@ Usage: emqtt_bench pub [--help ] [-d ] [-h []] [-p []] [ [-n []] [-i []] [-I []] [-u ] [-P ] [-t ] [--payload-hdrs []] [-s []] [-m ] [-q []] [-Q []] [-r []] [-k []] [-C []] [-x []] [-L []] - [-S []] [--certfile ] [--keyfile ] [--ws []] [--quic []] + [-S []] [--cacertfile ] [--certfile ] [--keyfile ] + [--ws []] [--quic []] [--load-qst ] [--ifaddr ] [--prefix ] [-s []] [-l ] [-F []] [-w []] [--max-random-wait []] [--min-random-wait []] [--num-retry-connect []] @@ -229,6 +233,7 @@ Usage: emqtt_bench pub [--help ] [-d ] [-h []] [-p []] [ -x, --session-expiry Set 'Session-Expiry' for persistent sessions (seconds) [default: 0] -L, --limit The max message count to publish, 0 means unlimited [default: 0] -S, --ssl ssl socoket for connecting to server [default: false] + --cacertfile CA certificate for server verification --certfile client certificate for authentication, if required by server --keyfile client private key for authentication, if required by server --ws websocket transport [default: false] diff --git a/src/emqtt_bench.erl b/src/emqtt_bench.erl index 5575d53..8269d03 100644 --- a/src/emqtt_bench.erl +++ b/src/emqtt_bench.erl @@ -106,6 +106,8 @@ "The max message count to publish, 0 means unlimited"}, {ssl, $S, "ssl", {boolean, false}, "ssl socoket for connecting to server"}, + {cacertfile, undefined, "cacertfile", string, + "CA certificate for server verification"}, {certfile, undefined, "certfile", string, "client certificate for authentication, if required by server"}, {keyfile, undefined, "keyfile", string, @@ -200,6 +202,8 @@ "Set 'Session-Expiry' for persistent sessions (seconds)"}, {ssl, $S, "ssl", {boolean, false}, "ssl socoket for connecting to server"}, + {cacertfile, undefined, "cacertfile", string, + "CA certificate for server verification"}, {certfile, undefined, "certfile", string, "client certificate for authentication, if required by server"}, {keyfile, undefined, "keyfile", string, @@ -268,6 +272,8 @@ "Set 'Session-Expiry' for persistent sessions (seconds)"}, {ssl, $S, "ssl", {boolean, false}, "ssl socoket for connecting to server"}, + {cacertfile, undefined, "cacertfile", string, + "CA certificate for server verification"}, {certfile, undefined, "certfile", string, "client certificate for authentication, if required by server"}, {keyfile, undefined, "keyfile", string, @@ -1091,6 +1097,8 @@ ssl_opts([{keyfile, KeyFile} | Opts], Acc) -> ssl_opts(Opts, [{keyfile, KeyFile}|Acc]); ssl_opts([{certfile, CertFile} | Opts], Acc) -> ssl_opts(Opts, [{certfile, CertFile}|Acc]); +ssl_opts([{cacertfile, CaCertFile} | Opts], Acc) -> + ssl_opts(Opts, [{cacertfile, CaCertFile}|Acc]); ssl_opts([_|Opts], Acc) -> ssl_opts(Opts, Acc).