openssl s_client returns errono=54 to github.com

errno=54 means that the connection was reset by the peer (ECONNRESET) or some device claiming to be the peer. Given that your infrastructure uses a proxy it is likely that the proxy is the cause of the problem.

Inside my macos I already installed all CA certificates inside Keychan App but didn't worked.

This does not help since it is not the local code having problems to check the server certificate. It does not even get the server certificate for verification which can be seen from the following output:

SSL handshake has read 0 bytes and written 316 bytes

This means that the TCP connection was successful, the ClientHello was written (316 bytes) but nothing received (0 bytes) which implicitly also no server certificate received. This kind of behavior is common with DPI based firewalls.

The interesting is that using curl works normally ...

curl and the browser might use an explicit proxy, in which case they will do a CONNECT request to build a tunnel through the proxy and not directly connect to the website. Check the https_proxy, http_proxy, HTTPS_PROXY or HTTP_PROXY variables. openssl s_client instead does not use a proxy.