I am trying to automate a TLS handshake and get the session information in a .pem file, using the following command:
openssl s_client -connect www.domain.com:443 -sess_out domain.pem
Every time that command is entered, a connection is started and waits for a user input (such as GET). My first goal would be to avoid that (just close the session when the session information is received, and move to the next domain). The second goal is to get the session information.
This thread gives a partial solution that works just fine when TLS 1.2 is negociated (as setting the session is part of the handshake): https://unix.stackexchange.com/questions/47852/openssl-s-client-hangs
So for readers trying to solve the issue for TLS 1.2, here is a good solution:
echo -n | openssl s_client -connect www.domaintls1-2.com:443 -sess_out ticket1-2.pem
Now my problem is that for TLS 1.3, the session information is sent AFTER the handshake. So I need to initiate a GET (or HEADER, or even send a bad request) to get the post-handshake new session ticket, and have it being saved in that .pem file.
It works fine when done manually, but using an echo isn't working (I tried echo "GET" | openssl ...
, openssl ... <<< GET
, openssl s_client -connect www.domaintls1-3.com:443 -sess_out test1_3.pem < /dev/null
, but in all these cases, I guess the connection is simply closed after the handshake and doesn't take the coming post-handshake tickets into account to be saved in the .pem file.
I'd be happy to test any suggestions, I am running out of ideas!
System: Ubuntu 20.01
OpenSSL version 1.1.1f 31 Mar 2020
Edit: Changed the title to emphasize that problem is with post-handshake information