@Override
    @SuppressWarnings("unused") // used by NativeCrypto.SSLHandshakeCallbacks / info_callback
    public final void onSSLStateChange(int type, int val) {
        if (type != NativeConstants.SSL_CB_HANDSHAKE_DONE) {
            // We only care about successful completion.
            return;
        }

        // First, update the state.
        synchronized (ssl) {
            if (state == STATE_CLOSED) {
                // Someone called "close" but the handshake hasn't been interrupted yet.
                return;
            }

            // Now that we've fixed up our state, we can tell waiting threads that
            // we're ready.
            transitionTo(STATE_READY);
        }

        // Let listeners know we are finally done
        notifyHandshakeCompletedListeners();

        synchronized (ssl) {
            // Notify all threads waiting for the handshake to complete.
            ssl.notifyAll();
        }
    }
Starts a TLS/SSL handshake on this connection using some native methods
from the OpenSSL library. It can negotiate new encryption keys, change
cipher suites, or initiate a new session. The certificate chain is
verified if the correspondent property in java.Security is set. All
listeners are notified at the end of the TLS/SSL handshake.
common/src/main/java/org/conscrypt/ConscryptFileDescriptorSocket.java