[erlang-questions] ssl timing issue in R15B?
Lukas P
lukasp.p017@REDACTED
Fri Mar 23 18:12:53 CET 2012
Hello.
I think that I have been hit by a SSL timing issue in R15B. My
functional test (= SSL/TCP client) crahes my server unless the test
contains a sleep.
The tested server implements a TCP based, line oriented protocol.
Switch to SSL can be started with a "STARTTLS\r\n" command.
The functional test starts a TCP connection and upgrades it to SSL:
upgrade_connection_to_ssl(Socket) ->
SendResult = gen_tcp:send(Socket, "STARTTLS\r\n"),
%timer:sleep(10), % workaround for a SSL timing bug
SslConnectResult = case SendResult of
ok ->
ssl:connect(Socket, [{active, false}, {packet, line}, list], 2000);
{error, Reason1} ->
{error, Reason1}
end,
...
After the server receives "STARTTLS\r\n", it performs ssl:ssl_accept
on the socket:
inet:setopts(Socket, [{active, false}]),
ssl:ssl_accept(Socket, [{cacertfile, ?SSL_CACERT_PATH}, {certfile,
?SSL_CERT_PATH}, {keyfile, ?SSL_KEY_PATH}], infinity),
First iteration of the test works right, i.e. connection is upgraded
to SSL and futher commands are performed over the secure connection,
and the connection is closed at the end of the test.
The second iteration of the test fails with {error,closed}, and the
server crashes with (see below).
The problem manifests also with R14B04.
Best regards, Lukas
=ERROR REPORT==== 23-Mar-2012::16:57:04 ===
** State machine <0.102.0> terminating
** Last message in was {tcp,#Port<0.2140>,
[22,3,1,0,103,1,0,0,99,3,1,79,108,157,80,51,140,
130,232,83,15,128,38,143,164,30,203,247,208,66,
205,100,0,158,84,84,251,121,182,34,167,164,117,
32,98,92,131,219,248,65,185,199,148,131,224,46,
71,92,29,58,19,77,33,81,29,143,208,128,239,202,
40,141,122,55,5,240,0,28,0,255,0,57,0,56,0,53,0,
22,0,19,0,10]}
** When State == hello
** Data == {state,server,
{#Ref<0.0.0.315>,<0.98.0>},
gen_tcp,tcp,tcp_closed,tcp_error,"localhost",8145,
#Port<0.2140>,
{ssl_options,[],verify_none,
{#Fun<ssl.1.24582685>,[]},
false,false,undefined,1,"../cert/server.crt",
undefined,"../cert/server.key",undefined,undefined,
undefined,"../cert/server.crt",undefined,undefined,
[<<0,57>>,
<<0,56>>,
<<0,53>>,
<<0,22>>,
<<0,19>>,
<<0,10>>,
<<0,51>>,
<<0,50>>,
<<0,47>>,
<<0,5>>,
<<0,4>>,
<<0,21>>,
<<0,9>>],
#Fun<ssl.0.123982462>,true,18446744073709551900,
false,[],undefined},
{socket_options,list,line,0,0,false},
{connection_states,
{connection_state,
{security_parameters,
<<0,0>>,
0,0,0,0,0,0,0,0,0,0,undefined,undefined,
undefined,undefined},
undefined,undefined,undefined,0,undefined,
undefined,undefined},
{connection_state,
{security_parameters,undefined,0,undefined,
undefined,undefined,undefined,undefined,
undefined,undefined,undefined,undefined,
undefined,undefined,
<<79,108,157,80,49,103,60,230,250,78,4,225,74,
55,176,84,223,46,97,9,131,243,182,44,18,190,
82,140,50,114,198,215>>,
undefined},
undefined,undefined,undefined,undefined,
undefined,undefined,undefined},
{connection_state,
{security_parameters,
<<0,0>>,
0,0,0,0,0,0,0,0,0,0,undefined,undefined,
undefined,undefined},
undefined,undefined,undefined,0,undefined,
undefined,undefined},
{connection_state,
{security_parameters,undefined,0,undefined,
undefined,undefined,undefined,undefined,
undefined,undefined,undefined,undefined,
undefined,undefined,
<<79,108,157,80,49,103,60,230,250,78,4,225,74,
55,176,84,223,46,97,9,131,243,182,44,18,190,
82,140,50,114,198,215>>,
undefined},
undefined,undefined,undefined,undefined,
undefined,undefined,undefined}},
[],<<>>,<<>>,
{{<<1,35,69,103,137,171,205,239,254,220,186,152,118,84,50,
16,0,0,0,0,0,0,0,0,189,33,38,64,88,194,157,155,162,
159,131,31,18,9,13,106,73,121,160,91,114,138,162,8,
220,130,60,229,78,11,83,20,0,0,12,139,24,32,103,93,
227,42,206,176,196,177,231,20,0,0,12,169,169,42,128,
92,250,14,14,51,66,235,147,0,0,0,0,0>>,
<<1,35,69,103,137,171,205,239,254,220,186,152,118,84,
50,16,240,225,210,195,0,0,0,0,0,0,0,0,189,33,38,64,
88,194,157,155,162,159,131,31,18,9,13,106,73,121,160,
91,114,138,162,8,220,130,60,229,78,11,83,20,0,0,12,
139,24,32,103,93,227,42,206,176,196,177,231,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>>},
{<<1,35,69,103,137,171,205,239,254,220,186,152,118,84,50,
16,0,0,0,0,0,0,0,0,189,33,38,64,88,194,157,155,162,
159,131,31,18,9,13,106,73,121,160,91,114,138,162,8,
220,130,60,229,78,11,83,20,0,0,12,139,24,32,103,93,
227,42,206,176,196,177,231,20,0,0,12,169,169,42,128,
92,250,14,14,51,66,235,147,0,0,0,0,0>>,
<<1,35,69,103,137,171,205,239,254,220,186,152,118,84,
50,16,240,225,210,195,0,0,0,0,0,0,0,0,189,33,38,64,
88,194,157,155,162,159,131,31,18,9,13,106,73,121,
160,91,114,138,162,8,220,130,60,229,78,11,83,20,0,0,
12,139,24,32,103,93,227,42,206,176,196,177,231,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>>}},
[],8207,
{session,undefined,undefined,
<<48,130,1,225,48,130,1,74,2,9,0,205,239,129,202,242,
227,65,139,48,13,6,9,42,134,72,134,247,13,1,1,5,5,0,
48,53,49,11,48,9,6,3,85,4,6,19,2,67,90,49,19,48,17,
6,3,85,4,8,19,10,83,111,109,101,45,83,116,97,116,
101,49,17,48,15,6,3,85,4,10,19,8,107,101,114,105,
111,100,101,118,48,30,23,13,49,50,48,51,50,51,48,56,
53,57,49,55,90,23,13,49,51,48,51,50,51,48,56,53,57,
49,55,90,48,53,49,11,48,9,6,3,85,4,6,19,2,67,90,49,
19,48,17,6,3,85,4,8,19,10,83,111,109,101,45,83,116,
97,116,101,49,17,48,15,6,3,85,4,10,19,8,107,101,114,
105,111,100,101,118,48,129,159,48,13,6,9,42,134,72,
134,247,13,1,1,1,5,0,3,129,141,0,48,129,137,2,129,
129,0,182,253,69,113,8,80,65,199,149,56,241,149,198,
94,125,152,3,192,219,198,133,171,8,242,113,152,14,
224,26,118,175,206,96,59,123,81,96,146,254,92,103,
250,224,113,228,227,140,94,205,242,108,108,225,220,
172,105,37,99,239,63,19,230,190,16,83,250,45,164,14,
164,224,143,179,72,236,132,28,137,144,46,24,159,152,
59,190,244,148,39,15,43,175,131,21,160,59,192,73,
137,91,70,221,121,198,143,80,106,191,0,130,145,216,
225,250,251,222,206,206,54,152,61,175,23,219,186,
129,100,155,215,2,3,1,0,1,48,13,6,9,42,134,72,134,
247,13,1,1,5,5,0,3,129,129,0,180,149,241,170,86,108,
137,169,31,219,111,106,43,252,244,75,48,216,124,147,
58,28,203,23,140,245,31,244,37,118,253,191,137,206,
133,193,86,9,20,240,89,32,211,234,245,53,100,147,63,
226,151,82,155,101,60,118,42,34,69,131,57,153,80,55,
117,141,243,94,159,60,126,188,217,46,136,159,152,19,
16,183,226,145,231,58,53,129,168,13,44,89,91,102,
186,146,95,214,176,97,185,153,244,5,180,96,0,6,95,
41,98,187,201,109,163,178,66,237,127,136,212,246,
211,75,111,62,17,99,37,192>>,
undefined,undefined,undefined,false,undefined},
20498,ssl_session_cache,undefined,undefined,false,
undefined,undefined,
{'RSAPrivateKey','two-prime',
128499485073324344640350663317080381746144189677328093733733818765201879966770636497130667046738574044411458592269074082861288662250357992465839585570810117635103294613076680912273164585128543701693490299026933362559737361586906453308454424637758883964954103891002397921983210876969561998056460034621497973719,
65537,
21142407304967520763185699719976162417697984303380210182505329321530919506258873206716205849596137203730545462874977887841879787677885930585152635171125398678264154737861602152192965103330738539906753643553236543949552679329988944514780005135078240922914424542757568267105592140259268438701514178052748528137,
12299880358440743957425671124001695744432582454465136498819080587852714118502292601888074183728961424894245227783505611233127931778382492533775859423958717,
10447214227180842802291362278552737574221362829069766492840722789131867364093400612139963591599836595829208168869120879147173486297418106712618120046723107,
8600926454775507180385181748794569671725229850667993278115886067108872585298733011265798918045239241650570979734539193914762452622788850082211271277006577,
5030482618477285446570769480206429034434037975448290602477603324177706309545683249420950471643743892069858586523686582895881009309056307025498420957847339,
1302418139310728515246909787183496859699357629051756870224989169538451919989096507242998571432647801516438823004677134366483529583874264214103765858188241,
asn1_NOVALUE},
{'DHParameter',
179769313486231590770839156793787453197860296048756011706444423684197180216158519368947833795864925541502180565485980503646440548199239100050792877003355816639229553136239076508735759914822574862575007425302077447712589550957937778424442426617334727629299387668709205606050270810842907692932019128194467627007,
2,asn1_NOVALUE},
undefined,undefined,#Ref<0.0.0.294>,undefined,0,<<>>,
true,
{false,first},
false,
{[],[]},
false}
** Reason for termination =
** {badarg,[{erlang,size,
[[22,3,1,0,103,1,0,0,99,3,1,79,108,157,80,51,140,130,232,
83,15,128,38,143,164,30,203,247,208,66,205,100,0,158,84,
84,251,121,182,34,167,164,117,32,98,92,131,219,248,65,
185,199,148,131,224,46,71,92,29,58,19,77,33,81,29,143,
208,128,239,202,40,141,122,55,5,240,0,28,0,255,0,57,0,
56,0,53,0,22,0,19,0,10]]},
{ssl_record,get_tls_records_aux,2},
{ssl_connection,next_tls_record,2},
{ssl_connection,handle_info,3},
{gen_fsm,handle_msg,7},
{proc_lib,init_p_do_apply,3}]}
More information about the erlang-questions
mailing list