Skip to content

Commit d239bbc

Browse files
lukebakkenmichaelklishin
authored andcommitted
Correctly add customize_hostname_check to ssl options
Follow-up to #11344 Prior to this fix, the `customize_hostname_check` option was incorrectly added to the general options passed to `httpc:request`, which results in the following error when the request is made: ``` [debug] <0.1.0> Enabling wildcard-aware hostname verification for HTTP client connections [notice] <0.1.0> Invalid option {customize_hostname_check, [notice] <0.1.0> [{match_fun,#Fun<public_key.6.112534691>}]} ignored [notice] <0.1.0> ``` With this fix, you can see that `customize_hostname_check` is added to the `ssl` section of the options: ``` 1> redbug:start("rabbit_auth_backend_http:ssl_options->return"). ... ... ... % rabbit_auth_backend_http:ssl_options/0 -> [{ssl, [{customize_hostname_check, [{match_fun, #Fun<public_key.6.112534691>}]}, {versions, ['tlsv1.3','tlsv1.2', 'tlsv1.1',tlsv1]}, {hibernate_after,6000}, {keyfile, "key.pem"}, {depth,10}, {crl_check,false}, {certfile, "certificate.pem"}, {cacertfile, "ca_certificate.pem"}, {fail_if_no_peer_cert,false}, {verify,verify_peer}]}] ``` (cherry picked from commit 4360e05)
1 parent eac2ae2 commit d239bbc

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

deps/rabbitmq_auth_backend_http/src/rabbit_auth_backend_http.erl

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
-define(SUCCESSFUL_RESPONSE_CODES, [200, 201]).
2727

28+
-define(APP, rabbitmq_auth_backend_http).
29+
2830
%%--------------------------------------------------------------------
2931

3032
description() ->
@@ -177,7 +179,7 @@ do_http_req(Path0, Query) ->
177179
{host, Host} = lists:keyfind(host, 1, URI),
178180
{port, Port} = lists:keyfind(port, 1, URI),
179181
HostHdr = rabbit_misc:format("~ts:~b", [Host, Port]),
180-
{ok, Method} = application:get_env(rabbitmq_auth_backend_http, http_method),
182+
{ok, Method} = application:get_env(?APP, http_method),
181183
Request = case rabbit_data_coercion:to_atom(Method) of
182184
get ->
183185
Path = Path0 ++ "?" ++ Query,
@@ -188,12 +190,12 @@ do_http_req(Path0, Query) ->
188190
{Path0, [{"Host", HostHdr}], "application/x-www-form-urlencoded", Query}
189191
end,
190192
RequestTimeout =
191-
case application:get_env(rabbitmq_auth_backend_http, request_timeout) of
193+
case application:get_env(?APP, request_timeout) of
192194
{ok, Val1} -> Val1;
193195
_ -> infinity
194196
end,
195197
ConnectionTimeout =
196-
case application:get_env(rabbitmq_auth_backend_http, connection_timeout) of
198+
case application:get_env(?APP, connection_timeout) of
197199
{ok, Val2} -> Val2;
198200
_ -> RequestTimeout
199201
end,
@@ -212,17 +214,10 @@ do_http_req(Path0, Query) ->
212214
end.
213215

214216
ssl_options() ->
215-
<<<<<<< HEAD
216-
case application:get_env(rabbitmq_auth_backend_http, ssl_options) of
217-
{ok, Opts0} when is_list(Opts0) ->
218-
Opts1 = [{ssl, rabbit_ssl_options:fix_client(Opts0)}],
219-
case application:get_env(rabbitmq_auth_backend_http, ssl_hostname_verification) of
220-
=======
221217
case application:get_env(?APP, ssl_options) of
222218
{ok, SslOpts0} when is_list(SslOpts0) ->
223219
SslOpts1 = rabbit_ssl_options:fix_client(SslOpts0),
224220
case application:get_env(?APP, ssl_hostname_verification) of
225-
>>>>>>> 4360e05df (Correctly add `customize_hostname_check` to `ssl` options)
226221
{ok, wildcard} ->
227222
?LOG_DEBUG("Enabling wildcard-aware hostname verification for HTTP client connections"),
228223
%% Needed for HTTPS connections that connect to servers that use wildcard certificates.
@@ -236,7 +231,7 @@ ssl_options() ->
236231
end.
237232

238233
p(PathName) ->
239-
{ok, Path} = application:get_env(rabbitmq_auth_backend_http, PathName),
234+
{ok, Path} = application:get_env(?APP, PathName),
240235
Path.
241236

242237
q(Args) ->

0 commit comments

Comments
 (0)