TlsStream.handshake

TlsProgress handshake()

Performs or continues the TLS handshake.

Call repeatedly until TlsProgress.DONE is returned. On NEED_READ, wait for transport readability and call again. On NEED_WRITE, wait for transport writability and call again.

The handshake never throws for TLS failures: every fatal condition — including certificate verification failures — is reported as TlsProgress.ERROR with the details available from lastError (TlsError.type == CERTIFICATE_ERROR for certificate problems). Exceptions are reserved for programming errors (e.g. wrong state).

Returns

TlsProgress.DONE when complete, NEED_READ or

NEED_WRITE when I/O is required, ERROR on failure (see lastError for the typed cause).