Skip to content

Commit f5dc8d3

Browse files
committed
Configure customize_hostname_check by default
HTTP requires us to do wildcard certificate matching so we now do it by default. That plus the previously added `cacerts` configuration by default (using `public_key:cacerts_get/0`) means that as far as certificates are concerned, the default should now be fully compliant. Users may want to keep configuring some options such as `depth` though.
1 parent 5a8d0f5 commit f5dc8d3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/gun.erl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,14 @@ ensure_tls_opts(Protocols0, TransOpts0, OriginHost) ->
12121212
end
12131213
end
12141214
end,
1215+
%% Wildcard certificate matching.
1216+
TransOpts2 = case lists:keymember(customize_hostname_check, 1, TransOpts1) of
1217+
true ->
1218+
TransOpts1;
1219+
false ->
1220+
HTTPSMatchFun = public_key:pkix_verify_hostname_match_fun(https),
1221+
[{customize_hostname_check, [{match_fun, HTTPSMatchFun}]}|TransOpts1]
1222+
end,
12151223
%% ALPN.
12161224
Protocols = lists:foldl(fun
12171225
(http, Acc) -> [<<"http/1.1">>|Acc];
@@ -1222,7 +1230,7 @@ ensure_tls_opts(Protocols0, TransOpts0, OriginHost) ->
12221230
end, [], Protocols0),
12231231
TransOpts = [
12241232
{alpn_advertised_protocols, Protocols}
1225-
|TransOpts1],
1233+
|TransOpts2],
12261234
%% SNI.
12271235
%%
12281236
%% Normally only DNS hostnames are supported for SNI. However, the ssl

0 commit comments

Comments
 (0)