As already mentioned above:
stream_socket_enable_crypto is likely to fail/return zero if the socket is in non-blocking mode.
You may either wait some seconds until all neccessary data has arrived or switch temporary to blocking mode:
stream_set_blocking ($fd, true);
stream_socket_enable_crypto ($fd, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
stream_set_blocking ($fd, false);
This works very fine for me ;-)