Skip to content

Commit 085b2f8

Browse files
author
Maciej Szlosarczyk
committed
Add insecure option to allow TLS connection without verification
1 parent 0ce33fd commit 085b2f8

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

apps/epp_proxy/src/epp_http_client.erl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ request_builder(Map) -> request_from_map(Map).
3131
handle_args(#epp_request{method = get, url = URL,
3232
headers = Headers, cookies = Cookies,
3333
epp_verb = ?helloCommand}) ->
34-
[get, URL, Headers, "", [{cookie, Cookies}, insecure]];
34+
[get, URL, Headers, "", hackney_options(Cookies)];
3535
%% For error command, we convert the message and code into query parameters,
3636
%% and append them to the original URL.
3737
handle_args(#epp_request{method = get, url = URL,
@@ -40,13 +40,13 @@ handle_args(#epp_request{method = get, url = URL,
4040
QueryString = hackney_url:qs(Payload),
4141
CompleteURL = [URL, <<"?">>, QueryString],
4242
[get, CompleteURL, Headers, "",
43-
[{cookie, Cookies}, insecure]];
43+
hackney_options(Cookies)];
4444
%% For valid commands, we set the multipart body earlier, now we just pass it on.
4545
handle_args(#epp_request{method = post, url = URL,
4646
payload = Payload, headers = Headers,
4747
cookies = Cookies}) ->
4848
[post, URL, Headers, Payload,
49-
[{cookie, Cookies}, insecure]].
49+
hackney_options(Cookies)].
5050

5151
%% Map request and return values.
5252
request_from_map(#{command := ?errorCommand,
@@ -82,6 +82,13 @@ request_from_map(#{command := Command,
8282
lager:info("Request from map: [~p]~n", [Request]),
8383
Request.
8484

85+
%% Get hackney options
86+
hackney_options(Cookies) ->
87+
case application:get_env(epp_proxy, insecure) of
88+
false -> [{cookies, Cookies}, insecure];
89+
_ -> [{cookies, Cookies}]
90+
end.
91+
8592
%% Return form data or an empty list.
8693
request_body(?helloCommand, _, _) -> "";
8794
request_body(_Command, RawFrame, nomatch) ->

config/sys.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
%% TLS port, specified in RFC to 700, but can be set to anything else
88
%% in case that is needed.
99
{tls_port, 700},
10+
%% When set to true, you can connect to EPP over endpoints without verifying their
11+
%% TLS certificates.
12+
{insecure, false}
1013
%% URL of EPP endpoints. Can be pointed at a web server (Apache/NGINX)
1114
%% Can contain port (https://some-host:3000/epp/session)
1215
%% Honors the prepended protocol (http / https).

config/test.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{epp_proxy, [{dev_mode, true},
33
{tcp_port, 1180},
44
{tls_port, 1443},
5+
{insecure, false},
56

67
{epp_session_url, "http://localhost:9292/session/"},
78
{epp_command_url, "http://localhost:9292/command/"},

0 commit comments

Comments
 (0)