possible bug in ssl and/or public_key module (R13 and R14)
Filipe David Manana
fdmanana@REDACTED
Fri Sep 17 03:11:17 CEST 2010
When connecting to particular server, though an ssl socket, I always get the
error:
Erlang R14B (erts-5.8.1) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe]
[kernel-poll:false]
Eshell V5.8.1 (abort with ^G)
1> c(test_ssl).
{ok,test_ssl}
2> test_ssl:test().
=ERROR REPORT==== 17-Sep-2010::02:07:25 ===
SSL: certify_certificate: ./ssl_handshake.erl:502:Fatal error: handshake
failure
** exception error: no match of right hand side value {error,esslconnect}
in function test_ssl:test/0
3>
However, if I pick up another server, like www.cia.gov:443 or
www.facebook.com:443 for example, it succeeds (with exactly the same ssl
options passed to ssl:connect/3).
Also tested with R13B03 and R13B04 and got the same results (only modified
value of option verify from verify_none to 0).
The code to test this eventual bug is:
-module(test_ssl).
-compile(export_all).
-define(HOST, "couchdb.staging.one.ubuntu.com").
% -define(HOST, "www.cia.gov").
test() ->
Body = iolist_to_binary([
"GET / HTTP/1.1\r\n",
"Host: ", ?HOST, "\r\n",
"Accept: */*\r\n",
"Connection: close\r\n", "\r\n"
]),
application:start(crypto),
application:start(public_key),
application:start(ssl),
Options = [
{ssl_imp, new},
binary,
{nodelay, true},
{active, false},
{verify, verify_none}
% {verify_fun, fun(_) -> true end},
],
{ok, S} = ssl:connect(?HOST, 443, Options),
ok = ssl:send(S, Body),
loop(S),
ssl:close(S).
loop(S) ->
ssl:setopts(S, [{active, once}]),
receive
{ssl, S, Data} ->
io:format("received data: ~p~n", [Data]),
loop(S);
{ssl_closed, S} ->
io:format("socket closed", []);
{ssl_error, S, Error} ->
io:format("socket error: ~p", [Error])
end.
cheers
--
Filipe David Manana,
fdmanana@REDACTED, fdmanana@REDACTED
"Reasonable men adapt themselves to the world.
Unreasonable men adapt the world to themselves.
That's why all progress depends on unreasonable men."
More information about the erlang-bugs
mailing list