verify method

  1. @Deprecated('Use validateConnection() instead — it composes fetchCertificate + verify ' 'in a single channel call and bounds the whole operation with one timeout. ' 'verify() will be removed in a future major release.')
Future<void> verify(
  1. String domain,
  2. String certificate
)

Verifies that certificate is valid for domain under this instance's pinning configuration. Returns normally on success.

Deprecated. Prefer validateConnection, which composes the certificate fetch and pin verification inside a single channel call. verify remains supported for diagnostic flows where the caller already holds a PEM certificate obtained out of band.

try {
  await TrustPin.shared.verify('api.example.com', pemCertificate);
} on TrustPinException catch (e) {
  if (e.isPinsMismatch) {
    // ...
  }
}

certificate must be a PEM string including the BEGIN/END markers. Behavior on unregistered domains depends on TrustPinMode.

  • Throws TrustPinException with code DOMAIN_NOT_REGISTERED if domain is not configured (strict mode only).
  • Throws TrustPinException with code PINS_MISMATCH if the certificate is rejected.
  • Throws TrustPinException with code ALL_PINS_EXPIRED if no usable pins remain for the domain.
  • Throws TrustPinException with code INVALID_SERVER_CERT if the certificate cannot be parsed.
  • Throws TrustPinException with code INVALID_PROJECT_CONFIG if setup has not been called.

Implementation

@Deprecated(
  'Use validateConnection() instead — it composes fetchCertificate + verify '
  'in a single channel call and bounds the whole operation with one timeout. '
  'verify() will be removed in a future major release.',
)
Future<void> verify(String domain, String certificate) async {
  try {
    await TrustPinSDKPlatform.instance
        .verify(domain, certificate, instanceId: _instanceId);
  } catch (e) {
    throw TrustPinException.fromPlatformException(e);
  }
}