.NET Based OPC UA Client/Server SDK  2.6.0.418
UnifiedAutomation.UaBase.SecurityUtils Class Reference

Provides various security related functions. More...

Static Public Member Functions

static ICertificateStore CreateStore (string storePath)
 Creates a new certificate store object. More...
 
static ICertificateStore CreateStore (string storePath, bool noPrivateKeys)
 Creates a new certificate store object. More...
 
static ICertificateStore CreateStore (string storeType, string storePath, bool noPrivateKeys)
 Creates a new certificate store object. More...
 
static bool IsWindowStorePath (string storePath)
 Determines whether the store path points to a windows certificate store. More...
 
static ICertificate LoadCertificate (byte[] bytes)
 Initializes a certificate with the DER encoded bytes. More...
 
static ICertificate LoadCertificate (byte[] bytes, string password)
 Initializes a certificate with the DER encoded bytes. More...
 
static ICertificate LoadCertificate (System.Security.Cryptography.X509Certificates.X509Certificate2 x509)
 Initializes a certificate with an x509 certificate. More...
 
static ICertificate[] LoadCertificateChain (byte[] bytes)
 Loads any certificate chain which has been appended the certificate in the byte buffer. More...
 
static ICertificate LoadCertificate (string storeType, string storePath, string subjectName, string thumbprint, bool needPrivateKey)
 Initializes a certificate with the DER encoded bytes. More...
 
static byte[] GetNonce (int length)
 Returns a new nonce. More...
 
static byte[] Concat (params byte[][] arrays)
 Concatinates a list of byte arrays. More...
 
static byte[] PSHA1 (byte[] secret, string label, byte[] data, int offset, int length)
 Generates a Pseudo random sequence of bits using the P_SHA1 alhorithm. More...
 
static byte[] PSHA256 (byte[] secret, string label, byte[] data, int offset, int length)
 Generates a Pseudo random sequence of bits using the P_SHA1 alhorithm. More...
 
static List< string > ParseDistinguishedName (string name)
 Parses a distingushed name. More...
 
static bool FindStringIgnoreCase (IList< string > strings, string target)
 Checks if the target is in the list. Comparisons ignore case. More...
 
static bool AreDomainsEqual (string domain1, string domain2)
 Checks if the domains are equal. More...
 
static IList< string > GetDomainsFromCertficate (X509Certificate2 certificate)
 Extracts the the DNS names specified in the certificate. More...
 
static string GetApplicationUriFromCertficate (X509Certificate2 certificate)
 Extracts the the application URI specified in the certificate. More...
 
static bool DoesUrlMatchCertificate (X509Certificate2 certificate, Uri endpointUrl)
 Checks that the domain in the URL provided matches one of the domains in the certificate. More...
 
static bool CompareDistinguishedName (string name1, string name2)
 Compares two distinguished names. More...
 
static bool CompareDistinguishedName (X509Certificate2 certificate, List< string > parsedName)
 Compares two distinguished names. More...
 
static string ChangeSubjectNameDelimiter (string name, char delimiter)
 Changes the delimiter used to seperate fields in a subject name. More...
 
static EncryptedData Encrypt (X509Certificate2 certificate, string securityPolicyUri, byte[] plainText)
 Encrypts the text using the SecurityPolicyUri and returns the result. More...
 
static byte[] Decrypt (X509Certificate2 certificate, string securityPolicyUri, EncryptedData dataToDecrypt)
 Decrypts the CipherText using the SecurityPolicyUri and returns the PlainTetx. More...
 
static SignatureData Sign (X509Certificate2 certificate, string securityPolicyUri, byte[] dataToSign)
 Signs the data using the SecurityPolicyUri and returns the signature. More...
 
static bool Verify (X509Certificate2 certificate, string securityPolicyUri, byte[] dataToVerify, SignatureData signature)
 Verifies the signature using the SecurityPolicyUri and return true if valid. More...
 
static bool CheckIfProcessHasAdminRights ()
 Checks if the process has admin rights. More...
 
static HashAlgorithm GetHashAlgorithm (ICertificate certificate)
 Gets the hash algorithm for the certificate. More...
 
static ushort GetHashSize (HashAlgorithm algorithm)
 Gets the hash size for the hash algorithm. More...
 
static ushort GetHashSize (ICertificate certificate)
 Gets the hash size for the certificate. More...
 
static PublicKeyAlgorithm GetPublicKeyAlgorithm (ICertificate certificate)
 Gets the public key algorithm for the certificate. More...
 
static ushort GetPublicKeySize (PublicKeyAlgorithm algorithm)
 Gets the key size for the public key algorithm. More...
 
static ushort GetPublicKeySize (ICertificate certificate)
 Gets the key size for the certificate. More...
 
static bool DoesCertificateSupportSecurityPolicy (ICertificate certificate, string securityPolicyUri)
 Checks if the certificate supports the security policy. More...
 

Detailed Description

Provides various security related functions.

Member Function Documentation

static bool UnifiedAutomation.UaBase.SecurityUtils.AreDomainsEqual ( string  domain1,
string  domain2 
)
inlinestatic

Checks if the domains are equal.

Parameters
domain1The first domain to compare.
domain2The second domain to compare.
Returns
True if they are equal.
static string UnifiedAutomation.UaBase.SecurityUtils.ChangeSubjectNameDelimiter ( string  name,
char  delimiter 
)
inlinestatic

Changes the delimiter used to seperate fields in a subject name.

static bool UnifiedAutomation.UaBase.SecurityUtils.CheckIfProcessHasAdminRights ( )
inlinestatic

Checks if the process has admin rights.

static bool UnifiedAutomation.UaBase.SecurityUtils.CompareDistinguishedName ( string  name1,
string  name2 
)
inlinestatic

Compares two distinguished names.

static bool UnifiedAutomation.UaBase.SecurityUtils.CompareDistinguishedName ( X509Certificate2  certificate,
List< string >  parsedName 
)
inlinestatic

Compares two distinguished names.

static byte [] UnifiedAutomation.UaBase.SecurityUtils.Concat ( params byte  arrays[][])
inlinestatic

Concatinates a list of byte arrays.

Parameters
arraysThe arrays.
Returns
The new array.
static ICertificateStore UnifiedAutomation.UaBase.SecurityUtils.CreateStore ( string  storePath)
inlinestatic

Creates a new certificate store object.

Parameters
storePathThe store path.
Returns
An object that can be used to access the store.
static ICertificateStore UnifiedAutomation.UaBase.SecurityUtils.CreateStore ( string  storePath,
bool  noPrivateKeys 
)
inlinestatic

Creates a new certificate store object.

Parameters
storePathThe store path.
noPrivateKeysif set to true then optimize performance by ignoring the private keys.
Returns
An object that can be used to access the store.
static ICertificateStore UnifiedAutomation.UaBase.SecurityUtils.CreateStore ( string  storeType,
string  storePath,
bool  noPrivateKeys 
)
inlinestatic

Creates a new certificate store object.

Parameters
storeTypeType of the store.
storePathThe store path.
noPrivateKeysif set to true then optimize performance by ignoring the private keys.
Returns
An object that can be used to access the store.
static byte [] UnifiedAutomation.UaBase.SecurityUtils.Decrypt ( X509Certificate2  certificate,
string  securityPolicyUri,
EncryptedData  dataToDecrypt 
)
inlinestatic

Decrypts the CipherText using the SecurityPolicyUri and returns the PlainTetx.

static bool UnifiedAutomation.UaBase.SecurityUtils.DoesCertificateSupportSecurityPolicy ( ICertificate  certificate,
string  securityPolicyUri 
)
inlinestatic

Checks if the certificate supports the security policy.

Parameters
certificateThe certificate.
securityPolicyUriThe security policy URI.
Returns
TRUE if the certificate supports the policy; FALSE otherwise.
static bool UnifiedAutomation.UaBase.SecurityUtils.DoesUrlMatchCertificate ( X509Certificate2  certificate,
Uri  endpointUrl 
)
inlinestatic

Checks that the domain in the URL provided matches one of the domains in the certificate.

Parameters
certificateThe certificate.
endpointUrlThe endpoint url to verify.
Returns
True if the certificate matches the url.
static EncryptedData UnifiedAutomation.UaBase.SecurityUtils.Encrypt ( X509Certificate2  certificate,
string  securityPolicyUri,
byte[]  plainText 
)
inlinestatic

Encrypts the text using the SecurityPolicyUri and returns the result.

static bool UnifiedAutomation.UaBase.SecurityUtils.FindStringIgnoreCase ( IList< string >  strings,
string  target 
)
inlinestatic

Checks if the target is in the list. Comparisons ignore case.

static string UnifiedAutomation.UaBase.SecurityUtils.GetApplicationUriFromCertficate ( X509Certificate2  certificate)
inlinestatic

Extracts the the application URI specified in the certificate.

Parameters
certificateThe certificate.
Returns
The application URI.
static IList<string> UnifiedAutomation.UaBase.SecurityUtils.GetDomainsFromCertficate ( X509Certificate2  certificate)
inlinestatic

Extracts the the DNS names specified in the certificate.

Parameters
certificateThe certificate.
Returns
The DNS names.
static HashAlgorithm UnifiedAutomation.UaBase.SecurityUtils.GetHashAlgorithm ( ICertificate  certificate)
inlinestatic

Gets the hash algorithm for the certificate.

Parameters
certificateThe certificate.
Returns
The hash algorithm.
static ushort UnifiedAutomation.UaBase.SecurityUtils.GetHashSize ( HashAlgorithm  algorithm)
inlinestatic

Gets the hash size for the hash algorithm.

Parameters
algorithmThe hash algorithm.
Returns
The hash size.
static ushort UnifiedAutomation.UaBase.SecurityUtils.GetHashSize ( ICertificate  certificate)
inlinestatic

Gets the hash size for the certificate.

Parameters
certificateThe certificate.
Returns
The hash size.
static byte [] UnifiedAutomation.UaBase.SecurityUtils.GetNonce ( int  length)
inlinestatic

Returns a new nonce.

Parameters
lengthThe length of the nonce.
Returns
The new nonce.
static PublicKeyAlgorithm UnifiedAutomation.UaBase.SecurityUtils.GetPublicKeyAlgorithm ( ICertificate  certificate)
inlinestatic

Gets the public key algorithm for the certificate.

Parameters
certificateThe certificate.
Returns
The public key algorithm.
static ushort UnifiedAutomation.UaBase.SecurityUtils.GetPublicKeySize ( PublicKeyAlgorithm  algorithm)
inlinestatic

Gets the key size for the public key algorithm.

Parameters
algorithmThe public key algorithm.
Returns
The key size.
static ushort UnifiedAutomation.UaBase.SecurityUtils.GetPublicKeySize ( ICertificate  certificate)
inlinestatic

Gets the key size for the certificate.

Parameters
certificateThe certificate.
Returns
The key size.
static bool UnifiedAutomation.UaBase.SecurityUtils.IsWindowStorePath ( string  storePath)
inlinestatic

Determines whether the store path points to a windows certificate store.

Parameters
storePathThe store path.
Returns
true if the store path points to a windows certificate store; otherwise, false.
static ICertificate UnifiedAutomation.UaBase.SecurityUtils.LoadCertificate ( byte[]  bytes)
inlinestatic

Initializes a certificate with the DER encoded bytes.

Parameters
bytesThe bytes.
Returns
The certificate object.
static ICertificate UnifiedAutomation.UaBase.SecurityUtils.LoadCertificate ( byte[]  bytes,
string  password 
)
inlinestatic

Initializes a certificate with the DER encoded bytes.

Parameters
bytesThe bytes.
passwordThe password.
Returns
The certificate object.
static ICertificate UnifiedAutomation.UaBase.SecurityUtils.LoadCertificate ( System.Security.Cryptography.X509Certificates.X509Certificate2  x509)
inlinestatic

Initializes a certificate with an x509 certificate.

Parameters
x509The x509 used to initialize the certificate object.
Returns
The certificate object.
static ICertificate UnifiedAutomation.UaBase.SecurityUtils.LoadCertificate ( string  storeType,
string  storePath,
string  subjectName,
string  thumbprint,
bool  needPrivateKey 
)
inlinestatic

Initializes a certificate with the DER encoded bytes.

Parameters
storeTypeType of the store.
storePathThe store path.
subjectNameName of the subject.
thumbprintThe thumbprint.
needPrivateKeyif set to true [need private key].
Returns
The certificate object.
static ICertificate [] UnifiedAutomation.UaBase.SecurityUtils.LoadCertificateChain ( byte[]  bytes)
inlinestatic

Loads any certificate chain which has been appended the certificate in the byte buffer.

Parameters
bytesThe bytes.
Returns
The chain.
static List<string> UnifiedAutomation.UaBase.SecurityUtils.ParseDistinguishedName ( string  name)
inlinestatic

Parses a distingushed name.

static byte [] UnifiedAutomation.UaBase.SecurityUtils.PSHA1 ( byte[]  secret,
string  label,
byte[]  data,
int  offset,
int  length 
)
inlinestatic

Generates a Pseudo random sequence of bits using the P_SHA1 alhorithm.

static byte [] UnifiedAutomation.UaBase.SecurityUtils.PSHA256 ( byte[]  secret,
string  label,
byte[]  data,
int  offset,
int  length 
)
inlinestatic

Generates a Pseudo random sequence of bits using the P_SHA1 alhorithm.

static SignatureData UnifiedAutomation.UaBase.SecurityUtils.Sign ( X509Certificate2  certificate,
string  securityPolicyUri,
byte[]  dataToSign 
)
inlinestatic

Signs the data using the SecurityPolicyUri and returns the signature.

static bool UnifiedAutomation.UaBase.SecurityUtils.Verify ( X509Certificate2  certificate,
string  securityPolicyUri,
byte[]  dataToVerify,
SignatureData  signature 
)
inlinestatic

Verifies the signature using the SecurityPolicyUri and return true if valid.


The documentation for this class was generated from the following file: