[erlang-questions] Re: ssl and {active, once} - bug?

Roberto Ostinelli roberto@REDACTED
Sun Apr 11 23:03:42 CEST 2010


ok,

here's the complete code to reproduce the error. this is the whole
picture, and i hope someone can tell me what i am doing wrong.


%%%%%%%%%%%%%%%%%%%%%%%%%%

-module(sslbug).
-compile(export_all).

start(Port) ->
	application:start(ssl),
	Options = [
		binary, {packet, http}, {reuseaddr, true}, {active, false}, {backlog, 128},
		{certfile, "/Users/roberto/Code/misultin/server.pem"},
		{keyfile, "/Users/roberto/Code/misultin/privkey.pem"},
		{password, "roberto"}
	],
	{ok, ListenSocket} = ssl:listen(Port, Options),
	{ok, Sock} = ssl:transport_accept(ListenSocket),
	ok = ssl:ssl_accept(Sock),
	ControllerPid = spawn(fun() ->
		receive
			set -> ok
		end,
		controller_loop(Sock)
	end),
	ok = ssl:controlling_process(Sock, ControllerPid),
	ControllerPid ! set.
	
controller_loop(Sock) ->
	ssl:setopts(Sock, [{active, once}]),
	receive
		_Any ->
			ok
	end,
	ssl:close(Sock).

%%%%%%%%%%%%%%%%%%%%%%%%%%


compile and run this code with c(sslbug), then start the server with
the command sslbug:start(8080). point your browser to
https://localhost:8080 and you should receive the following error:

=ERROR REPORT==== 11-Apr-2010::23:00:20 ===
** Generic server <0.80.0> terminating
** Last message in was {http,#Port<0.2159>,
                             {http_request,'GET',{abs_path,"/"},{1,1}}}
** When Server state == {st,acceptor,<0.70.0>,<0.81.0>,<0.81.0>,6,once,
                            [{mode,binary},
                             {packet,http},
                             {active,once},
                             {nodelay,false},
                             {ip,{0,0,0,0}},
                             {verify,0},
                             {depth,1}],
                            {sslsocket,6,<0.80.0>},
                            #Port<0.2159>,57732,open,true,false}
** Reason for termination ==
** {error,{badinfo,{http,#Port<0.2159>,
                         {http_request,'GET',{abs_path,"/"},{1,1}}}}}


More information about the erlang-questions mailing list