fix(sni): fix bad type of sni

This commit is contained in:
zhouzb 2021-09-09 10:18:40 +08:00
parent 1a291d5d97
commit 1a694814e0
3 changed files with 7 additions and 3 deletions

View File

@ -65,7 +65,10 @@ save_files_return_opts(Options, Dir) ->
false -> verify_none;
_ -> verify_peer
end,
SNI = Get(<<"server_name_indication">>),
SNI = case Get(<<"server_name_indication">>) of
undefined -> undefined;
SNI0 -> ensure_str(SNI0)
end,
Versions = emqx_tls_lib:integral_versions(Get(<<"tls_versions">>)),
Ciphers = emqx_tls_lib:integral_ciphers(Versions, Get(<<"ciphers">>)),
filter([{keyfile, Key}, {certfile, Cert}, {cacertfile, CA},
@ -81,6 +84,7 @@ save_file(Param, SubDir) ->
filter([]) -> [];
filter([{_, ""} | T]) -> filter(T);
filter([{_, undefined} | T]) -> filter(T);
filter([H | T]) -> [H | filter(T)].
do_save_file(#{<<"filename">> := FileName, <<"file">> := Content}, Dir)

View File

@ -345,7 +345,7 @@ pool_opts(Params = #{<<"url">> := URL}, ResId) ->
cuttlefish_duration:parse(str(maps:get(<<"connect_timeout">>, Params, <<"5s">>))),
TransportOpts0 =
case Scheme =:= https of
true -> [get_ssl_opts(Params, ResId)];
true -> get_ssl_opts(Params, ResId);
false -> []
end,
TransportOpts = emqx_misc:ipv6_probe(TransportOpts0),

View File

@ -64,7 +64,7 @@ translate_env() ->
SNI0 -> SNI0
end,
TLSOpts = lists:filter(fun({_K, V}) ->
V /= <<>> andalso V /= undefined andalso V /= "" andalso true
V /= <<>> andalso V /= undefined andalso V /= ""
end, [{keyfile, KeyFile},
{certfile, CertFile},
{cacertfile, CACertFile},