I'm new to cowboy and am attempting to get a version of the ssl_hello_world app to run. I've replaced the files in the priv/ssl directory with soft links to my certificate files. I've copied the toppage_h.erl file into my src directory generated by rebar3. I've included the dependency for cowboy in the rebar.config file. The code below fails on line 19. The error indicates that there is something wrong with my use of cowboy:start_tls on line 19.
Any help is greatly appreciated.
exited: {bad_return,
{{ssl_try_app,start,[normal,[]]},
{'EXIT',
{undef,
[{cowboy,start_tls,
[https,
[{port,443},
{cacertfile,
"/home/pseudo/ssl_try/_build/default/lib/ssl_try/priv/ssl/cacert"},
{certfile,
"/home/pseudo/ssl_try/_build/default/lib/ssl_try/priv/ssl/cert"},
{keyfile,
"/home/pseudo/ssl_try/_build/default/lib/ssl_try/priv/ssl/privkey"}],
#{env => #{dispatch => [{'_',[],[{[],[],toppage_h,[]}]}]}}],
[]},
{ssl_try_app,start,2,
[{file,"/home/pseudo/ssl_try/src/ssl_try_app.erl"},
{line,19}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},{line,277}]}]}}}}
Here is the source code.
-behaviour(application).
-export([start/2, stop/1]).
start(_Type, _Args) ->
Dispatch = cowboy_router:compile([
{'_', [
{"/", toppage_h, []}
]}
]),
PrivDir = code:priv_dir(ssl_try),
{ok, _} = cowboy:start_tls(https, [
{port, 443},
{cacertfile, PrivDir ++ "/ssl/cacert"},
{certfile, PrivDir ++ "/ssl/cert"},
{keyfile, PrivDir ++ "/ssl/privkey"}
], #{env => #{dispatch => Dispatch}}),
ssl_try_sup:start_link().
stop(_State) ->
ok.