Skip to content

Function: tlsHandshake() ​

tlsHandshake(host, port, options?): Effect<DiagnosticStep>

Defined in: diagnostics.ts:209

Tests TLS/SSL connectivity and validates the server certificate.

Performs a TLS handshake and retrieves certificate information including the Common Name (CN) and expiration date. Useful for diagnosing HTTPS connectivity issues and certificate problems.

Parameters ​

host ​

Host

A validated Host type (Hostname or IpAddress)

port ​

Port

A validated Port branded type (typically 443 for HTTPS)

options? ​

TlsHandshakeOptions = {}

Optional configuration including timeoutMs (as TimeoutMs) and rejectUnauthorized

Returns ​

Effect<DiagnosticStep>

An Effect that resolves to a DiagnosticStep with certificate info or error

Example ​

typescript
import { Hostname, Port } from '@univ-lehavre/atlas-net';

// Check TLS connectivity and certificate
const step = await Effect.runPromise(tlsHandshake(Hostname('example.com'), Port(443)));
if (step.status === 'ok') {
  console.log(`Certificate: ${step.message}`);
}

// Allow self-signed certificates
const step2 = await Effect.runPromise(
  tlsHandshake(Hostname('internal-server.local'), Port(443), { rejectUnauthorized: false })
);