TrustPinDioInterceptor class

A certificate pinning interceptor for the Dio HTTP client.

This interceptor adds TrustPin certificate validation to all HTTPS requests made through Dio. It validates certificates in two phases:

  1. Standard TLS validation (handled by the OS)
  2. TrustPin certificate pinning validation

Certificates are cached to avoid repeated socket connections to the same host. The cache stores certificates but not validation results, so TrustPin verification is performed on every request.

Usage

final dio = Dio();
dio.interceptors.add(TrustPinDioInterceptor());

// Now all HTTPS requests will have certificate pinning
final response = await dio.get('https://api.example.com/data');

Important Notes

  • TrustPin must be initialized with TrustPin.setup before using this interceptor
  • Only HTTPS requests are validated; HTTP requests pass through unchanged
  • Certificate validation happens before the actual HTTP request is sent
  • Failed validation prevents the request from being sent
Inheritance

Constructors

TrustPinDioInterceptor.new()
Creates a new TrustPinDioInterceptor.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clearCertificateCache() → void
Clears the certificate cache.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onError(DioException err, ErrorInterceptorHandler handler) → void
Called when an exception was occurred during the request.
inherited
onRequest(RequestOptions options, RequestInterceptorHandler handler) → void
Called when the request is about to be sent.
override
onResponse(Response response, ResponseInterceptorHandler handler) → void
Called when the response is about to be resolved.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited