certificateHashes method

List<WebTransportHash> certificateHashes()

The SHA-256 digest of the identity's leaf certificate.

Hand this to WebTransportOptions.serverCertificateHashes on the client side to trust a server that is not signed by a public CA — the portable way to connect to a self-signed server.

Implementation

List<WebTransportHash> certificateHashes() {
  final out = calloc<Uint8>(32);
  try {
    final status = b.wt_server_config_certificate_hash(_handle, out);
    if (status != b.wt_status_t.WT_OK) {
      throw WebTransportException(
        status.value,
        'the configuration has no usable identity',
        operation: 'wt_server_config_certificate_hash',
      );
    }
    return <WebTransportHash>[
      WebTransportHash(value: Uint8List.fromList(out.asTypedList(32))),
    ];
  } finally {
    calloc.free(out);
  }
}