使用TLS分发运行escript

时间:2016-01-16 04:42:11

标签: erlang

通过%为vm提供参数时,我无法进行TLS分发工作!在escript中划线。

cat test.es
#!/usr/bin/env escript
%%! +P 256000 -env ERL_MAX_ETS_TABLES 256000 -env ERL_CRASH_DUMP /dev/null -env ERL_FULLSWEEP_AFTER 0 -env ERL_MAX_PORTS 65536 +A 64 +K true +W w -smp auto -boot /tmp/start_clean -proto_dist inet_tls -ssl_dist_opt server_certfile "/var/lib/cinched/cert.pem" server_cacertfile "/var/lib/cinched/cacert.pem" client_certfile "/var/lib/cinched/cert.pem" client_cacertfile "/var/lib/cinched/cacert.pem" server_keyfile "/var/lib/cinched/key.pem" client_keyfile "/var/lib/cinched/key.pem" -name test@192.168.101.1

main(_) ->
        io:format("Ping: ~p~n",[net_adm:ping('cinched@192.168.101.1')]).


[root@dev1 ~]# ./test.es
{error_logger,{{2016,1,15},{23,36,42}},"Protocol: ~tp: not supported~n",["inet_tls"]}
{error_logger,{{2016,1,15},{23,36,42}},crash_report,[[{initial_call,{net_kernel,init,['Argument__1']}},{pid,<0.21.0>},{registered_name,[]},{error_info,{exit,{error,badarg},[{gen_server,init_it,6,[{file,"gen_server.erl"},{line,322}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,237}]}]}},{ancestors,[net_sup,kernel_sup,<0.10.0>]},{messages,[]},{links,[<0.18.0>]},{dictionary,[{longnames,true}]},{trap_exit,true},{status,running},{heap_size,376},{stack_size,27},{reductions,211}],[]]}
{error_logger,{{2016,1,15},{23,36,42}},supervisor_report,[{supervisor,{local,net_sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offender,[{pid,undefined},{name,net_kernel},{mfargs,{net_kernel,start_link,[['test@192.168.101.1',longnames]]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]}]}
{error_logger,{{2016,1,15},{23,36,42}},supervisor_report,[{supervisor,{local,kernel_sup}},{errorContext,start_error},{reason,{shutdown,{failed_to_start_child,net_kernel,{'EXIT',nodistribution}}}},{offender,[{pid,undefined},{name,net_sup},{mfargs,{erl_distribution,start_link,[]}},{restart_type,permanent},{shutdown,infinity},{child_type,supervisor}]}]}
{error_logger,{{2016,1,15},{23,36,42}},crash_report,[[{initial_call,{application_master,init,['Argument__1','Argument__2','Argument__3','Argument__4']}},{pid,<0.9.0>},{registered_name,[]},{error_info,{exit,{{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,net_kernel,{'EXIT',nodistribution}}}}},{kernel,start,[normal,[]]}},[{application_master,init,4,[{file,"application_master.erl"},{line,133}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,237}]}]}},{ancestors,[<0.8.0>]},{messages,[{'EXIT',<0.10.0>,normal}]},{links,[<0.8.0>,<0.7.0>]},{dictionary,[]},{trap_exit,true},{status,running},{heap_size,376},{stack_size,27},{reductions,164}],[]]}
{error_logger,{{2016,1,15},{23,36,42}},std_info,[{application,kernel},{exited,{{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,net_kernel,{'EXIT',nodistribution}}}}},{kernel,start,[normal,[]]}}},{type,permanent}]}
{"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,net_kernel,{'EXIT',nodistribution}}}}},{kernel,start,[normal,[]]}}}"}

它所指向的启动文件似乎没有被考虑在内。我尝试过其他变种(尝试通过-s开关启动相关应用程序),但到目前为止似乎没有任何工作。

启动文件:

{release,{"start_clean",[]},
         {erts,"6.4"},
         [{kernel,"3.2"},
          {stdlib,"2.4"},
          {sasl,"2.4.1"},
          {crypto,"3.5"},
          {asn1,"3.0.4"},
          {public_key,"0.23"},
          {ssl,"6.0"}
          ]}.

1 个答案:

答案 0 :(得分:0)

Erlang ssl distribution需要一个已启动的Relationship Seque应用程序,该应用程序应包含在boot script中,并传递给带有ssl标志的模拟器。但似乎escript没有基于此示例传递-boot标志:

发布文件

-boot

escript来源

{release,
 {"foo_rel", "0.1"},
 {erts, "6.4"},
 [{kernel, "3.2"},
  {stdlib, "2.4"},
  {crypto, "3.5"},
  {asn1, "3.0.4"},
  {public_key, "0.23"},
  {ssl, "6.0"}]
}.

escript结果

#!/usr/bin/env escript
%%! -sname foo -boot /path/to/foo
main(_) ->
    io:format("~p~n", [application:which_applications()]).

但是使用[{stdlib,"ERTS CXC 138 10","2.4"}, {kernel,"ERTS CXC 138 10","3.2"}] 启动foo版本会以确认启动文件正确的方式启动启动文件中的所有已定义应用程序:

erl

虽然我不知道为什么escript没有将启动脚本传递给模拟器,但显然使用启动文件escript不会启动$ erl -boot /path/to/foo Erlang/OTP 17 [erts-6.4] [...] 1> application:which_applications(). [{ssl,"Erlang/OTP SSL application","6.0"}, {public_key,"Public key infrastructure","0.23"}, {asn1,"The Erlang ASN1 compiler version 3.0.4","3.0.4"}, {crypto,"CRYPTO","3.5"}, {stdlib,"ERTS CXC 138 10","2.4"}, {kernel,"ERTS CXC 138 10","3.2"}] 应用程序,因此无法启动ssl分发模式。