CertificatePinningDatasource class
Pure-Dart datasource for TLS certificate pinning validation.
Opens a TLS connection to the host, lets the platform validate the certificate chain as usual, and then compares the SHA-256 fingerprint of the leaf certificate's Subject Public Key Info (SPKI) (or of the whole certificate, see PinningMode) against the provided pins.
Accepted pin formats: sha256/<base64>, bare base64 / base64url, or
64 hex characters.
Constructors
- CertificatePinningDatasource({PinningMode mode = PinningMode.publicKey, SecurityContext? securityContext})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- mode → PinningMode
-
Public key (default) or whole-certificate pinning.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- securityContext → SecurityContext?
-
Optional trust store, e.g. for a private CA.
nulluses the platform's.final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
validateCertificate(
{required String host, required List< String> pins, Duration timeout = const Duration(seconds: 10)}) → Future<bool> -
Returns
truewhen the certificate served byhostmatches one ofpins,falseon a mismatch or whenpinsis empty.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
parseHost(
String input) → ({String host, int port}) -
Splits
host/host:port/[v6]:port. Throws ArgumentError for URLs, paths, credentials or anything else that is not a plain host.