UtilSecurityContext class

(en) A utility for creating a SecurityContext that trusts specific certificates (e.g. a self-signed certificate of a local server). Pass the result to securityContext of HttpsServiceForNative. Unlike CertificatePinner, normal TLS verification (including host name and expiry) is still performed. This class is not available in Flutter web.

(ja) 特定の証明書(ローカルサーバーの自己署名証明書など)を信頼する SecurityContextを作成するユーティリティです。 結果はHttpsServiceForNativeのsecurityContextに渡します。 CertificatePinnerとは異なり、通常のTLS検証(ホスト名や有効期限を含む)が そのまま行われます。 このクラスはFlutter webでは利用できません。

Author Masahide Mori

First edition creation date 2026-10-22

Constructors

UtilSecurityContext()

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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

fromAsset(String assetPath, {bool withTrustedRoots = false}) → Future<SecurityContext>
(en) Creates a SecurityContext from a PEM file bundled in the app's assets. See fromPem for details.
fromPem(String pem, {bool withTrustedRoots = false}) → SecurityContext
(en) Creates a SecurityContext that trusts the certificates in the PEM. If the PEM contains multiple certificates, all of them are trusted. Throws a TlsException if the PEM is invalid.