【发布时间】:2015-09-10 17:53:06
【问题描述】:
我在 OSX 上创建了一个新的 Phoenix Web 应用程序,我正在尝试让 SSL 在 localhost 上运行。为此,我阅读并执行了this article 的步骤。所以现在我有一个 server.key、server.crt 和 server.csr 文件。这些文件不是二进制文件并且是可读的形式。我将这些文件作为Phoenix docs suggested 放在priv 文件夹中。
我的配置文件如下所示:
config :{{name}}, {{name}}.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
cache_static_lookup: false,
check_origin: false,
watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin"]],
https: [port: 4043,
otp_app: :{{name}},
keyfile: System.get_env("server.key"),
certfile: System.get_env("server.crt"),
# OPTIONAL Key for intermediate certificates
# cacertfile: System.get_env("INTERMEDIATE_CERTFILE_PATH")
]
当我运行 mix phoenix.server 时出现以下错误:
** (Mix) Could not start application {{name}}: {{name}}.start(:normal, []) returned an error: shutdown: failed to start child: {{name}}.Endpoint
** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Server
** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, {{name}}.Endpoint.HTTPS}
** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup
** (EXIT) an exception was raised:
** (MatchError) no match of right hand side value: {:error, {:options, {:certfile, nil}}}
(ranch) src/ranch_acceptors_sup.erl:30: :ranch_acceptors_sup.init/1
(stdlib) supervisor.erl:243: :supervisor.init/1
(stdlib) gen_server.erl:306: :gen_server.init_it/6
(stdlib) proc_lib.erl:237: :proc_lib.init_p_do_apply/3
我做错了什么?我是 Phoenix 新手,我正在做的项目需要 localhost 上的 SSL 以防止跨域问题。
【问题讨论】:
-
你把密钥文件和证书文件放在哪里了?它们是否放置在“priv/static”中?似乎找不到您的证书文件。
标签: ssl openssl elixir phoenix-framework