fix(ssl): fix the issue that the content of TLS certificate is not converted to path
This commit is contained in:
parent
c202688abf
commit
81d425cb27
|
@ -107,29 +107,25 @@ do_pre_config_update({move_authenticator, _ChainName, AuthenticatorID, Position}
|
||||||
post_config_update(_, UpdateReq, NewConfig, OldConfig, AppEnvs) ->
|
post_config_update(_, UpdateReq, NewConfig, OldConfig, AppEnvs) ->
|
||||||
do_post_config_update(UpdateReq, check_configs(to_list(NewConfig)), OldConfig, AppEnvs).
|
do_post_config_update(UpdateReq, check_configs(to_list(NewConfig)), OldConfig, AppEnvs).
|
||||||
|
|
||||||
do_post_config_update({create_authenticator, ChainName, Config}, _NewConfig, _OldConfig, _AppEnvs) ->
|
do_post_config_update({create_authenticator, ChainName, Config}, NewConfig, _OldConfig, _AppEnvs) ->
|
||||||
NConfig = check_config(Config),
|
NConfig = get_authenticator_config(authenticator_id(Config), NewConfig),
|
||||||
_ = emqx_authentication:create_chain(ChainName),
|
_ = emqx_authentication:create_chain(ChainName),
|
||||||
emqx_authentication:create_authenticator(ChainName, NConfig);
|
emqx_authentication:create_authenticator(ChainName, NConfig);
|
||||||
do_post_config_update({delete_authenticator, ChainName, AuthenticatorID}, _NewConfig, OldConfig, _AppEnvs) ->
|
do_post_config_update({delete_authenticator, ChainName, AuthenticatorID}, _NewConfig, OldConfig, _AppEnvs) ->
|
||||||
case emqx_authentication:delete_authenticator(ChainName, AuthenticatorID) of
|
case emqx_authentication:delete_authenticator(ChainName, AuthenticatorID) of
|
||||||
ok ->
|
ok ->
|
||||||
[Config] = [Config0 || Config0 <- to_list(OldConfig), AuthenticatorID == authenticator_id(Config0)],
|
Config = get_authenticator_config(AuthenticatorID, to_list(OldConfig)),
|
||||||
CertsDir = certs_dir(ChainName, AuthenticatorID),
|
CertsDir = certs_dir(ChainName, AuthenticatorID),
|
||||||
ok = clear_certs(CertsDir, Config);
|
ok = clear_certs(CertsDir, Config);
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
{error, Reason}
|
{error, Reason}
|
||||||
end;
|
end;
|
||||||
do_post_config_update({update_authenticator, ChainName, AuthenticatorID, Config}, _NewConfig, _OldConfig, _AppEnvs) ->
|
do_post_config_update({update_authenticator, ChainName, AuthenticatorID, Config}, NewConfig, _OldConfig, _AppEnvs) ->
|
||||||
NConfig = check_config(Config),
|
NConfig = get_authenticator_config(authenticator_id(Config), NewConfig),
|
||||||
emqx_authentication:update_authenticator(ChainName, AuthenticatorID, NConfig);
|
emqx_authentication:update_authenticator(ChainName, AuthenticatorID, NConfig);
|
||||||
do_post_config_update({move_authenticator, ChainName, AuthenticatorID, Position}, _NewConfig, _OldConfig, _AppEnvs) ->
|
do_post_config_update({move_authenticator, ChainName, AuthenticatorID, Position}, _NewConfig, _OldConfig, _AppEnvs) ->
|
||||||
emqx_authentication:move_authenticator(ChainName, AuthenticatorID, Position).
|
emqx_authentication:move_authenticator(ChainName, AuthenticatorID, Position).
|
||||||
|
|
||||||
check_config(Config) ->
|
|
||||||
[Checked] = check_configs([Config]),
|
|
||||||
Checked.
|
|
||||||
|
|
||||||
check_configs(Configs) ->
|
check_configs(Configs) ->
|
||||||
Providers = emqx_authentication:get_providers(),
|
Providers = emqx_authentication:get_providers(),
|
||||||
lists:map(fun(C) -> do_check_conifg(C, Providers) end, Configs).
|
lists:map(fun(C) -> do_check_conifg(C, Providers) end, Configs).
|
||||||
|
@ -208,6 +204,10 @@ clear_certs(CertsDir, Config) ->
|
||||||
OldSSL = maps:get(<<"ssl">>, Config, undefined),
|
OldSSL = maps:get(<<"ssl">>, Config, undefined),
|
||||||
ok = emqx_tls_lib:delete_ssl_files(CertsDir, undefined, OldSSL).
|
ok = emqx_tls_lib:delete_ssl_files(CertsDir, undefined, OldSSL).
|
||||||
|
|
||||||
|
get_authenticator_config(AuthenticatorID, AuthenticatorsConfig) ->
|
||||||
|
[C] = [C0 || C0 <- AuthenticatorsConfig, AuthenticatorID == authenticator_id(C0)],
|
||||||
|
C.
|
||||||
|
|
||||||
split_by_id(ID, AuthenticatorsConfig) ->
|
split_by_id(ID, AuthenticatorsConfig) ->
|
||||||
case lists:foldl(
|
case lists:foldl(
|
||||||
fun(C, {P1, P2, F0}) ->
|
fun(C, {P1, P2, F0}) ->
|
||||||
|
|
Loading…
Reference in New Issue