verify method
- @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.')
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_REGISTEREDif domain is not configured (strict mode only). - Throws TrustPinException with code
PINS_MISMATCHif the certificate is rejected. - Throws TrustPinException with code
ALL_PINS_EXPIREDif no usable pins remain for the domain. - Throws TrustPinException with code
INVALID_SERVER_CERTif the certificate cannot be parsed. - Throws TrustPinException with code
INVALID_PROJECT_CONFIGif 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);
}
}