Skip to content

Commit

Permalink
Merge pull request #21 from internetee/disable-crl-check-with-a-featu…
Browse files Browse the repository at this point in the history
…re-flag

When no CRL file is defined, CRL check should be disabled completely
  • Loading branch information
Maciej Szlosarczyk authored Jul 31, 2019
2 parents 236a0ed + a1ca280 commit 9e7a3d8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ of Erlang property list.
| `cacertfile_path` | `/opt/ca/ca.crt.pem` | SSLCACertificateFile | Where is the client root CA located. Can be inside apps/epp_proxy/priv or absolute path.
| `certfile_path` | `/opt/ca/server.crt.pem` | SSLCertificateFile | Where is the server certificate located. Can be inside apps/epp_proxy/priv or absolute path.
| `keyfile_path` | `/opt/ca/server.key.pem` | SSLCertificateKeyFile | Where is the server key located. Can be inside apps/epp_proxy/priv or absolute path.
| `crlfile_path` | `/opt/ca/crl.pem` | SSLCARevocationFile | Where is the CRL file located. Can be inside apps/epp_proxy/priv or absolute path.
| `crlfile_path` | `/opt/ca/crl.pem` | SSLCARevocationFile | Where is the CRL file located. Can be inside apps/epp_proxy/priv or absolute path. When not set, not CRL check is performed.


Migrating from mod_epp
Expand Down
26 changes: 19 additions & 7 deletions apps/epp_proxy/src/epp_tls_acceptor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ start_link(Port) ->
[]).

init(Port) ->
Options = [binary, {packet, raw}, {active, false},
{reuseaddr, true}, {verify, verify_peer}, {depth, 1},
{cacertfile, ca_cert_file()}, {certfile, cert_file()},
{keyfile, key_file()}, {crl_check, peer},
{crl_cache,
{ssl_crl_cache, {internal, [{http, 5000}]}}}],
ssl_crl_cache:insert({file, crl_file()}),
DefaultOptions = [binary, {packet, raw},
{active, false}, {reuseaddr, true},
{verify, verify_peer}, {depth, 1},
{cacertfile, ca_cert_file()}, {certfile, cert_file()},
{keyfile, key_file()}],
Options = handle_crl_check_options(DefaultOptions),
{ok, ListenSocket} = ssl:listen(Port, Options),
gen_server:cast(self(), accept),
{ok,
Expand Down Expand Up @@ -88,3 +87,16 @@ crl_file() ->
undefined -> undefined;
{ok, CrlFile} -> epp_util:path_for_file(CrlFile)
end.

%% In some environments, we do not perform a CRL check. Therefore, we need
%% different options proplist.
handle_crl_check_options(Options) ->
case application:get_env(epp_proxy, crlfile_path) of
undefined -> Options;
{ok, _CrlFile} ->
ssl_crl_cache:insert({file, crl_file()}),
NewOptions = [{crl_check, peer},
{crl_cache, {ssl_crl_cache, {internal, [{http, 5000}]}}}
| Options],
NewOptions
end.
3 changes: 2 additions & 1 deletion config/docker.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
{cacertfile_path, "/opt/ca/certs/ca.crt.pem"},
{certfile_path, "/opt/ca/certs/apache.crt"},
{keyfile_path, "/opt/ca/private/apache.key"},
{crlfile_path, "/opt/ca/crl/crl.pem"}]},
{crlfile_path, "/opt/ca/crl/crl.pem"}
]},
{lager, [
{handlers, [
{lager_console_backend, [{level, debug}]}
Expand Down
2 changes: 1 addition & 1 deletion config/sys.config
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
%% Path to server's key file.
{keyfile_path, "/opt/shared/ca/certs/key.pem"},

%% Path to CRL file.
%% Path to CRL file. When this option is undefined, no CRL check is performed.
{crlfile_path, "/opt/shared/ca/certs/key.pem"}]},
{lager, [
{handlers, [
Expand Down

0 comments on commit 9e7a3d8

Please sign in to comment.