openssl / openssl

TLS/SSL and crypto library
https://www.openssl.org
Apache License 2.0
25.85k stars 10.13k forks source link

openssl 1.1.1w s_client connect block #24058

Open linxingyang opened 7 months ago

linxingyang commented 7 months ago

Hello. i'm get trouble when using opnessl.

env:

using openssl s_client to test connect like this:

openssl s_client -connect server_ip:server_port -key client.key -cert client.crt -CAfile ca.crt -state  -brief

it's works fine in my arm linux shell. so after that i run 30 processes, every process do that repeatly (Test scenario), c++ code like this :

while (true) {
    // ....download cert from server 
    openssl s_client -connect server_ip:server_port -key client.key -cert client.crt -CAfile ca.crt -state  -brief
    // ....record result
}

but i found some processes were blocked (the timestamp stop update) like this screenshot :

17121987535935

i add some logs to openssl 1.1.1w source code, finally found it block in apps/s_client.c line 2874, the timeoutp is NULL so block forever ( in normal case, it will have read/write incidents few seconds later, but in my test case, it already block more than 10 minutes).

#else
            i = select(width, (void *)&readfds, (void *)&writefds,
                       NULL, timeoutp);
#endif

so, is that a bug ? or just waiting longer select() will return? or i'm misusing openssl s_client connect ?

Hope to get your reply. thanks.

nhorman commented 7 months ago

The first question I would ask is, why are the read and write fds in the read and write set not readable/writeable? This suggests that something wen't wrong with the connection attempt in those processes. Have you looked at the tcpdumps of the connections when these hung processes occur?