fetchCertificate method

  1. @Deprecated('Use validateConnection() instead — it keeps the certificate inside the ' 'platform layer instead of marshalling it through the Dart isolate. ' 'fetchCertificate() will be removed in a future major release.')
Future<String> fetchCertificate(
  1. String host, {
  2. int port = 443,
  3. Duration? timeout,
})

Returns the TLS leaf certificate served by host:port as a PEM string.

Deprecated. Prefer validateConnection, which keeps the certificate inside the platform layer instead of marshalling it through the Dart isolate. fetchCertificate remains supported for diagnostic flows where the caller needs the PEM bytes (for example, to display the SHA-256 fingerprint).

timeout is an optional upper bound on the call; when null, the platform default is used.

Implementation

@Deprecated(
  'Use validateConnection() instead — it keeps the certificate inside the '
  'platform layer instead of marshalling it through the Dart isolate. '
  'fetchCertificate() will be removed in a future major release.',
)
Future<String> fetchCertificate(
  String host, {
  int port = 443,
  Duration? timeout,
}) async {
  try {
    return await TrustPinSDKPlatform.instance.fetchCertificate(
      host,
      port: port,
      timeoutMs: timeout?.inMilliseconds,
      instanceId: _instanceId,
    );
  } catch (e) {
    throw TrustPinException.fromPlatformException(e);
  }
}