我想用ssl嵌入yaws,但它显示错误消息,有人能告诉我如何设置SSL属性吗?
以下是我的代码
Id = "my_server",
GconfList = [{logdir, "/Users/james/Documents/workspaces/erlang/embed_yaws/log"},
{ebin_dir, ["/Users/james/Documents/workspaces/erlang/embed_yaws/ebin"]},
{id, Id}],
Docroot = "/Users/james/Documents/workspaces/erlang/embed_yaws/www",
SconfList = [
{docroot, Docroot},
{port, 4444},
{listen, {0,0,0,0}},
{ssl,[{keyfile, "/Users/james/Develop/yaws-2.0.2/etc/yaws/yaws-key.pem"},
{certfile, "/Users/james/Develop/yaws-2.0.2/etc/yaws/yaws-cert.pem"},
{depth,0},{dhfile,"/Users/james/Develop/yaws-2.0.2/etc/yaws/dhparams.pem"}]},
{appmods, [{"/rest", myappmod1, []},{"/ws", myws, []}]}
],
yaws:start_embedded(Docroot, SconfList, GconfList, Id)
部分错误消息在
下面=ERROR REPORT==== 16-Oct-2015::17:10:17 ===
FATAL: {noproc,
{gen_server,call,
......
=ERROR REPORT==== 16-Oct-2015::17:10:17 ===
** Generic server yaws_server terminating
** Last message in was {setconf,
.........
** When Server state == {state,undefined,[],0,true}
** Reason for termination ==
** {badbind,[{yaws_server,start_group,2,
[{file,"src/yaws_server.erl"},{line,271}]},
{lists,filtermap,2,[{file,"lists.erl"},{line,1315}]},
{yaws_server,init2,5,[{file,"src/yaws_server.erl"},{line,248}]},
{yaws_server,handle_call,3,
[{file,"src/yaws_server.erl"},{line,314}]},
{gen_server,try_handle_call,4,
[{file,"gen_server.erl"},{line,607}]},
{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,639}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,237}]}]}
答案 0 :(得分:1)
ssl
应用程序未运行。在致电yaws:start_embedded/4
之前,请按以下方式启动ssl
:
application:ensure_all_started(ssl),
yaws:start_embedded(Docroot, SconfList, GconfList, Id)
如果您使用的旧版Erlang没有提供application:ensure_all_started/1
,这是任何早于R16B02的版本,您可以这样开始ssl
:
[application:start(App) || App <- [crypto, public_key, ssl]],