fetchCertificate method
- @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.')
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.
- Throws TrustPinException with code
INVALID_SERVER_CERTon connection failure. - Throws TrustPinException with code
FETCH_CERTIFICATE_TIMEOUTiftimeoutis exceeded.
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);
}
}