X509TrustManagerExtensions.SetNetworkSecurityPolicy Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets the NetworkSecurityPolicy to be used by this TrustManager.
[Android.Runtime.Register("setNetworkSecurityPolicy", "(Landroid/security/NetworkSecurityPolicy;)V", "GetSetNetworkSecurityPolicy_Landroid_security_NetworkSecurityPolicy_Handler", ApiSince=37)]
public virtual void SetNetworkSecurityPolicy(Android.Security.NetworkSecurityPolicy policy);
[<Android.Runtime.Register("setNetworkSecurityPolicy", "(Landroid/security/NetworkSecurityPolicy;)V", "GetSetNetworkSecurityPolicy_Landroid_security_NetworkSecurityPolicy_Handler", ApiSince=37)>]
abstract member SetNetworkSecurityPolicy : Android.Security.NetworkSecurityPolicy -> unit
override this.SetNetworkSecurityPolicy : Android.Security.NetworkSecurityPolicy -> unit
Parameters
- policy
- NetworkSecurityPolicy
the NetworkSecurityPolicy to associate with this TrustManager. Must not be null.
- Attributes
Remarks
Sets the NetworkSecurityPolicy to be used by this TrustManager.
This method allows an application to associate a specific security policy with this X509TrustManager instance. When a policy is set, it overrides the default process-wide policy returned by NetworkSecurityPolicy.getInstance() for all certificate verifications performed by this TrustManager.
The TrustManager will query the provided policy for security decisions, including: Whether cleartext traffic is permitted for a specific hostname; Whether Certificate Transparency (CT) verification is required for a hostname; The domain encryption mode (e.g., Encrypted Client Hello) to be used
By using a custom NetworkSecurityPolicy, applications can programmatically define granular security constraints that differ from the global application configuration. This is useful for specialized network stacks or for enforcing stricter security on specific sensitive connections.
Android reference for android.net.http.X509TrustManagerExtensions.setNetworkSecurityPolicy.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.