2

我目前正在处理 SSL 套接字。我将其设置为:

{ok, LSocket} = ssl:listen(443, [{packet, http},
                         {reuseaddr, true},
                         {active, false},
                         {certfile, "mycert.pem"},
                         {keyfile, "mykey.pem"}]).

但是当我通过调用将套接字传递给另一个应该处理连接的进程时:

ssl:getopts(LSocket, [packet]).

我有:

{ok,[{packet,0}]}

代替:

{ok,[{packet,http}]

0 不是表示“原始数据包”吗?为什么会这样?

4

1 回答 1

0

你自己编译过 Erlang 吗?可能你把加密模块搞砸了。尝试使用 Erlang Solutions 的预编译 15B02:https ://www.erlang-solutions.com/downloads/download-erlang-otp

您演示的代码在那里可以很好地传递给另一个进程:

Erlang R15B02 (erts-5.9.2) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.9.2  (abort with ^G)
1> {ok, LSocket} = ssl:listen(9443, [{packet, http}, {reuseaddr, true}, {active, false}, {certfile, "priv/ssl/ssl.crt"}, {keyfile, "priv/ssl/ssl.key"}]).
{ok,{sslsocket,new_ssl,
               {#Port<0.719>,
                {config,{ssl_options,[],verify_none,
                                     {#Fun<ssl.1.38762831>,[]},
                                     false,false,undefined,1,<<"priv/ssl/ssl.crt">>,undefined,
                                     <<"priv/ssl/ssl.key">>,undefined,[],undefined,<<>>,
                                     undefined,undefined,
                                     [<<0,...>>,<<...>>|...],
                                     #Fun<ssl.0.38762831>,true,...},
                        [{packet,http},{reuseaddr,true},{active,false}],
                        {socket_options,list,http,0,0,false},
                        [{reuseaddr,true},
                         {packet_size,0},
                         {packet,0},
                         {header,0},
                         {active,false},
                         {mode,binary}],
                        {gen_tcp,tcp,tcp_closed,tcp_error}}}}}
2> 
2> ssl:getopts(LSocket, [packet]).
{ok,[{packet,http}]}
3> spawn(fun() -> ssl:getopts(LSocket, [packet]) end).
<0.42.0>
4> spawn(fun() -> error_logger:info_msg(ssl:getopts(LSocket, [packet])) end).
<0.44.0>
5> 
=INFO REPORT==== 1-Nov-2012::06:07:15 ===
ERROR: {ok,[{packet,http}]} - []
于 2012-11-01T02:11:33.540 回答