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

Roberto Ostinelli <>
Mon Apr 12 12:46:21 CEST 2010


2010/4/12 Ingela Andin <>:
> Hi!
>
> Actually it is the new ssl implementation that has driven the http
> packet support to become a supported feature in the inet driver. I
> think the reason it does proably not work with the old ssl is that it
> was never a supported feature when some one still actively cared about
> that implementation. We are currently working hard at making the new
> ssl implementation complete enough to be able to phase out the old
> one.
>
> Regards Ingela Erlang/OTP Team, Ericsson AB

hi ingela,

thank you for your anwser. tony did give a working suggestion [code
here below], can this be a viable solution meanwhile, or do you have a
better way to implement this?

also, do you happen to know minimum erlang version which allows the
implementation here below?


2010/4/12 Tony Rogvall <>:
> But if you call crypto:start add the option {ssl_imp, new} the code will work :-)

indeed.

here's the code for others' reference, now working.


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

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

start(Port) ->
	application:start(ssl),
	application:start(crypto),
	Options = [
		binary, {packet, http}, {reuseaddr, true}, {active, false},
		{backlog, 128}, {ssl_imp, new},
		{certfile, "/Users/roberto/Code/sslbug/server.pem"},
		{keyfile, "/Users/roberto/Code/sslbug/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 ->
			io:format("ok, received ~p~n", [_Any])
	end,
	ssl:close(Sock).

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


More information about the erlang-questions mailing list