Class IdentityPolicyRule
Represents a rule that defines how to handle identity validation for secure network connections.
Namespace: System.Net.Security
Assembly: System (in System.dll)
Inheritance: Object → IdentityPolicyRule
Syntax
public sealed class IdentityPolicyRule
Remarks
The IdentityPolicyRule class is used in conjunction with classes like TrustPolicy to configure the security policies for network connections. It allows developers to define specific rules for validating the identity of remote endpoints, such as ensuring that a server's certificate is valid and matches the expected identity.
This class is particularly useful when implementing custom authentication mechanisms or when needing fine-grained control over the trust decisions made during the SSL/TLS handshake.
Fields
| Name | Description |
|---|---|
| IdentityConstraint | Defines the constraints for identity validation. |
| IdentityType | Specifies the type of identity to be validated. |
| RuleType | Indicates the type of policy rule. |
Constructors
IdentityPolicyRule(IdentityPolicyRuleType, IdentityType, IdentityConstraint)
Initializes a new instance of the IdentityPolicyRule class with the specified rule type, identity type, and identity constraint.
public IdentityPolicyRule(IdentityPolicyRuleType ruleType, IdentityType identityType, IdentityConstraint identityConstraint);
Parameters:
ruleType: AnIdentityPolicyRuleTypeenumeration value that specifies the type of policy rule.identityType: AnIdentityTypeenumeration value that specifies the type of identity to be validated.identityConstraint: AnIdentityConstraintobject that defines the constraints for identity validation.
Methods
IsIdentityMatch(string, System.Security.Cryptography.X509Certificates.X509Certificate)
Determines whether the specified identity matches the criteria defined by this policy rule.
public bool IsIdentityMatch(string identity, System.Security.Cryptography.X509Certificates.X509Certificate certificate);
Parameters:
identity: The identity string to compare against the certificate.certificate: TheX509Certificateto validate against the identity.
Returns: true if the identity matches the certificate according to the rule; otherwise, false.
Properties
IdentityConstraint
Gets the identity constraints defined by this policy rule.
public IdentityConstraint IdentityConstraint { get; }
IdentityType
Gets the type of identity that this policy rule applies to.
public IdentityType IdentityType { get; }
RuleType
Gets the type of this policy rule.
public IdentityPolicyRuleType RuleType { get; }
Requirements
Namespace: System.Net.Security
Platforms:
- Windows 7, Windows Vista, Windows XP SP2
- .NET Framework 3.5, .NET Framework 4.0
Assembly: System.dll