【问题标题】:How to embed Yaws with SSL?如何使用 SSL 嵌入 Yaws?
【发布时间】:2023-04-10 17:24:01
【问题描述】:

我想用 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}]}]}

【问题讨论】:

  • 如果您要提供更多错误消息的致命部分而不是截断它,将会很有帮助。
  • 谢谢,我会记住的。

标签: yaws


【解决方案1】:

ssl 应用程序未运行。在调用yaws:start_embedded/4 之前,请像这样开始ssl

application:ensure_all_started(ssl),
yaws:start_embedded(Docroot, SconfList, GconfList, Id)

如果您使用的是不提供 application:ensure_all_started/1 的旧版 Erlang,即任何早于 R16B02 的版本,您可以像这样启动 ssl

[application:start(App) || App <- [crypto, public_key, ssl]],

【讨论】:

  • 在我添加 application:ensure_all_started(ssl) 后,它可以工作并且没有任何错误消息。非常感谢
猜你喜欢
  • 2017-02-28
  • 2018-06-30
  • 2016-06-13
  • 2016-08-11
  • 1970-01-01
  • 2013-12-28
  • 1970-01-01
  • 2012-01-11
  • 2015-09-11
相关资源
最近更新 更多