fetchCertificate method

  1. @override
Future<String> fetchCertificate(
  1. String host, {
  2. int port = 443,
  3. int? timeoutMs,
  4. String? instanceId,
})
override

Fetches the TLS leaf certificate from host as a PEM string.

When timeoutMs is non-null and positive, the platform throws FETCH_CERTIFICATE_TIMEOUT if exceeded. When instanceId is null, the global default instance is used.

Deprecated. Implementations and callers should prefer validateConnection, which keeps the certificate inside the platform layer instead of marshalling it through the Dart isolate.

Implementation

@override
Future<String> fetchCertificate(String host,
    {int port = 443, int? timeoutMs, String? instanceId}) async {
  final result = await methodChannel.invokeMethod<String>(
    'fetchCertificate',
    {
      'host': host,
      'port': port,
      'timeoutMs': timeoutMs,
      'instanceId': instanceId,
    },
  );
  return result!;
}