Class DtlsUtils
This class provides various utility functions for the Datagram Transport Layer Security (DTLS) protocol.
Assembly: SipLib.dll
Syntax
Fields
|
Edit this page
View Source
DEFAULT_ECDSA_KEY_SIZE
The key size in bits when generating random keys for ECDSA self signed certificates.
This is the maximum maximum key size for ECDSA keys.
Declaration
public const int DEFAULT_ECDSA_KEY_SIZE = 384
Field Value
|
Edit this page
View Source
DEFAULT_KEY_SIZE
The key size in bits when generating random keys for RSA self signed certificates.
Declaration
public const int DEFAULT_KEY_SIZE = 2048
Field Value
Methods
|
Edit this page
View Source
ConvertBouncyCert(X509Certificate, AsymmetricCipherKeyPair)
Declaration
public static X509Certificate2 ConvertBouncyCert(X509Certificate bouncyCert, AsymmetricCipherKeyPair keyPair)
Parameters
Type |
Name |
Description |
X509Certificate |
bouncyCert |
|
AsymmetricCipherKeyPair |
keyPair |
|
Returns
|
Edit this page
View Source
CreateCertificateFromPfxFile(string, string)
Creates a BouncyCastle Certificate object and its private key from a PFX file containing a .NET
X509Certificate2 object
Declaration
public static (Certificate, AsymmetricKeyParameter) CreateCertificateFromPfxFile(string CertFileName, string CertPassword)
Parameters
Type |
Name |
Description |
string |
CertFileName |
File name of the *.PFX file containing a private key.
|
string |
CertPassword |
Password of the X.509 certificate
|
Returns
Type |
Description |
(Certificate, AsymmetricKeyParameter) |
Returns a BouncyCastle Certificate object and its private key.
|
|
Edit this page
View Source
CreateEcdsaPrivateKeyResource(string)
Creates a private key for ECDSA certificates
Declaration
public static AsymmetricKeyParameter CreateEcdsaPrivateKeyResource(string subjectName = "CN=root")
Parameters
Type |
Name |
Description |
string |
subjectName |
Subject Name for the private key. Defaults to "CN=root"
|
Returns
Type |
Description |
AsymmetricKeyParameter |
Returns a new private key.
|
|
Edit this page
View Source
CreatePrivateKeyResource(string)
Declaration
public static AsymmetricKeyParameter CreatePrivateKeyResource(string subjectName = "CN=root")
Parameters
Type |
Name |
Description |
string |
subjectName |
Subject Name for the private key. Defaults to "CN=root"
|
Returns
Type |
Description |
AsymmetricKeyParameter |
Returns a new private key.
|
|
Edit this page
View Source
CreateSelfSignedBouncyCastleCert()
Creates a self-signed BouncyCastle X509Certificate and its private key.
Declaration
public static (X509Certificate certificate, AsymmetricKeyParameter privateKey) CreateSelfSignedBouncyCastleCert()
Returns
Type |
Description |
(X509Certificate certificate, AsymmetricKeyParameter privateKey) |
Returns a self-signed BouncyCastle X509Certificate and its private key
|
|
Edit this page
View Source
CreateSelfSignedCert(AsymmetricKeyParameter?)
Creates an X.509 self-signed certificate for use with DTLS using RSA and SHA-256.
Declaration
public static X509Certificate2 CreateSelfSignedCert(AsymmetricKeyParameter? privateKey = null)
Parameters
Type |
Name |
Description |
AsymmetricKeyParameter |
privateKey |
Private key to use. May be null
|
Returns
|
Edit this page
View Source
CreateSelfSignedCert(string, string, AsymmetricKeyParameter)
Creates an X.509 self-signed certificate for use with DTLS using RSA and SHA-256.
Declaration
public static X509Certificate2 CreateSelfSignedCert(string subjectName, string issuerName, AsymmetricKeyParameter privateKey)
Parameters
Type |
Name |
Description |
string |
subjectName |
Subject name for the certificate. For example: "CN=localhost"
|
string |
issuerName |
Issuer name for the certificate. For example: "CN=root"
|
AsymmetricKeyParameter |
privateKey |
Private key to use. May be null.
|
Returns
|
Edit this page
View Source
CreateSelfSignedEcdsaTlsCert(string, string, AsymmetricKeyParameter)
Creates a self-signed ECDSA BouncyCastle TLS certificate and its private key.
Declaration
public static (Certificate certificate, AsymmetricKeyParameter privateKey) CreateSelfSignedEcdsaTlsCert(string subjectName, string issuerName, AsymmetricKeyParameter issuerPrivateKey)
Parameters
Type |
Name |
Description |
string |
subjectName |
Subject Name for the certificate. For example: "CN=localhost"
|
string |
issuerName |
Issuer Name for the certificate. For example: "CN=root"
|
AsymmetricKeyParameter |
issuerPrivateKey |
The private key of the certificate issuer to use. May
be null
|
Returns
Type |
Description |
(Certificate, AsymmetricKeyParameter) |
|
|
Edit this page
View Source
CreateSelfSignedTlsCert()
Creates a self-signed BouncyCastle TLS certificate and its private key.
Declaration
public static (Certificate certificate, AsymmetricKeyParameter privateKey) CreateSelfSignedTlsCert()
Returns
Type |
Description |
(Certificate, AsymmetricKeyParameter) |
Returns a self-signed (Org.BouncyCastle.Crypto.Tls.Certificate certificate and
its private key.
|
|
Edit this page
View Source
CreateSelfSignedTlsCert(string, string, AsymmetricKeyParameter)
Creates a self-signed BouncyCastle TLS certificate and its private key.
Declaration
public static (Certificate certificate, AsymmetricKeyParameter privateKey) CreateSelfSignedTlsCert(string subjectName, string issuerName, AsymmetricKeyParameter issuerPrivateKey)
Parameters
Type |
Name |
Description |
string |
subjectName |
Subject Name for the certificate. For example: "CN=localhost"
|
string |
issuerName |
Issuer Name for the certificate. For example: "CN=root"
|
AsymmetricKeyParameter |
issuerPrivateKey |
|
Returns
Type |
Description |
(Certificate, AsymmetricKeyParameter) |
|
|
Edit this page
View Source
DigestOf(IDigest, byte[])
Calculates the digest of a byte array
Declaration
public static byte[] DigestOf(IDigest dAlg, byte[] input)
Parameters
Type |
Name |
Description |
IDigest |
dAlg |
Specifies the hash algorithm to use
|
byte[] |
input |
Input byte array to calculate the hash of
|
Returns
Type |
Description |
byte[] |
Returns a byte array containing the calculated hash value
|
|
Edit this page
View Source
Fingerprint(X509CertificateStructure)
Gets the fingerprint of a BouncyCastle X509CertificateStructure using the SHA-256 hash algorithm
Declaration
public static RTCDtlsFingerprint Fingerprint(X509CertificateStructure c)
Parameters
Type |
Name |
Description |
X509CertificateStructure |
c |
Input certificate structure
|
Returns
Type |
Description |
RTCDtlsFingerprint |
Returns a RTCDtlsFingerprint object that represents the fingerprint of the X.509 certificate
|
|
Edit this page
View Source
Fingerprint(Certificate)
Gets the fingerprint of the first BouncyCastle X.509 certificate in a BouncyCastle certificate chain
Declaration
public static RTCDtlsFingerprint Fingerprint(Certificate certificateChain)
Parameters
Type |
Name |
Description |
Certificate |
certificateChain |
The certificate chain the contains at least one certificate
|
Returns
Type |
Description |
RTCDtlsFingerprint |
Returns a RTCDtlsFingerprint object that represents the fingerprint of the X.509 certificate
|
|
Edit this page
View Source
Fingerprint(X509Certificate)
Gets the fingerprint of a BouncyCastle X.509 certificate
Declaration
public static RTCDtlsFingerprint Fingerprint(X509Certificate certificate)
Parameters
Type |
Name |
Description |
X509Certificate |
certificate |
Input BouncyCastle X.509 certificate
|
Returns
Type |
Description |
RTCDtlsFingerprint |
Returns a RTCDtlsFingerprint object that represents the fingerprint of the X.509 certificate
|
|
Edit this page
View Source
Fingerprint(X509Certificate2)
Gets the fingerprint of a .NET X.509 certificate
Declaration
public static RTCDtlsFingerprint Fingerprint(X509Certificate2 certificate)
Parameters
Returns
Type |
Description |
RTCDtlsFingerprint |
Returns a RTCDtlsFingerprint object that represents the fingerprint of the X.509 certificate
|
|
Edit this page
View Source
Fingerprint(string, X509CertificateStructure)
Gets the fingerprint of a BouncyCastle X.509 certificate
Declaration
public static RTCDtlsFingerprint Fingerprint(string hashAlgorithm, X509CertificateStructure c)
Parameters
Type |
Name |
Description |
string |
hashAlgorithm |
Specifies the hash algorithm. For example sha-256.
|
X509CertificateStructure |
c |
BouncyCastle X.509 certificate object
|
Returns
Type |
Description |
RTCDtlsFingerprint |
Returns a RTCDtlsFingerprint object that represents the fingerprint of the X.509 certificate
|
|
Edit this page
View Source
Fingerprint(string, X509Certificate2)
Gets the fingerprint of an .NET X.509 certificate.
Declaration
public static RTCDtlsFingerprint Fingerprint(string hashAlgorithm, X509Certificate2 certificate)
Parameters
Type |
Name |
Description |
string |
hashAlgorithm |
Specifies the hash algorithm. For example sha-256.
|
X509Certificate2 |
certificate |
X509Certificate2 certificate to get the fingerprint attribute.
|
Returns
Type |
Description |
RTCDtlsFingerprint |
Returns a RTCDtlsFingerprint object that represents the fingerprint of the X.509 certificate
|
|
Edit this page
View Source
IsHashSupported(string)
Verifies the hash algorithm is supported by the utility functions in this class.
Declaration
public static bool IsHashSupported(string hashAlgorithm)
Parameters
Type |
Name |
Description |
string |
hashAlgorithm |
The hash algorithm to check.
|
Returns
Type |
Description |
bool |
True if the hash algorithm is supported.
|
|
Edit this page
View Source
LoadAgreementCredentials(TlsContext, Certificate, AsymmetricKeyParameter)
Declaration
public static TlsAgreementCredentials LoadAgreementCredentials(TlsContext context, Certificate certificate, AsymmetricKeyParameter privateKey)
Parameters
Type |
Name |
Description |
TlsContext |
context |
|
Certificate |
certificate |
|
AsymmetricKeyParameter |
privateKey |
|
Returns
Type |
Description |
TlsAgreementCredentials |
|
|
Edit this page
View Source
LoadAgreementCredentials(TlsContext, string[], string)
Declaration
public static TlsAgreementCredentials LoadAgreementCredentials(TlsContext context, string[] certResources, string keyResource)
Parameters
Type |
Name |
Description |
TlsContext |
context |
|
string[] |
certResources |
|
string |
keyResource |
|
Returns
Type |
Description |
TlsAgreementCredentials |
|
|
Edit this page
View Source
LoadCertificateChain(X509Certificate2)
Declaration
public static Certificate LoadCertificateChain(X509Certificate2 certificate)
Parameters
Returns
Type |
Description |
Certificate |
|
|
Edit this page
View Source
LoadCertificateChain(X509Certificate2[])
Declaration
public static Certificate LoadCertificateChain(X509Certificate2[] certificates)
Parameters
Returns
Type |
Description |
Certificate |
|
|
Edit this page
View Source
LoadCertificateChain(string[])
Declaration
public static Certificate LoadCertificateChain(string[] resources)
Parameters
Type |
Name |
Description |
string[] |
resources |
|
Returns
Type |
Description |
Certificate |
|
|
Edit this page
View Source
LoadCertificateResource(X509Certificate2)
Declaration
public static X509CertificateStructure LoadCertificateResource(X509Certificate2 certificate)
Parameters
Returns
Type |
Description |
X509CertificateStructure |
|
|
Edit this page
View Source
LoadCertificateResource(string)
Declaration
public static X509CertificateStructure LoadCertificateResource(string resource)
Parameters
Type |
Name |
Description |
string |
resource |
|
Returns
Type |
Description |
X509CertificateStructure |
|
|
Edit this page
View Source
LoadEncryptionCredentials(TlsContext, Certificate, AsymmetricKeyParameter)
Declaration
public static TlsEncryptionCredentials LoadEncryptionCredentials(TlsContext context, Certificate certificate, AsymmetricKeyParameter privateKey)
Parameters
Type |
Name |
Description |
TlsContext |
context |
|
Certificate |
certificate |
|
AsymmetricKeyParameter |
privateKey |
|
Returns
Type |
Description |
TlsEncryptionCredentials |
|
|
Edit this page
View Source
LoadEncryptionCredentials(TlsContext, string[], string)
Declaration
public static TlsEncryptionCredentials LoadEncryptionCredentials(TlsContext context, string[] certResources, string keyResource)
Parameters
Type |
Name |
Description |
TlsContext |
context |
|
string[] |
certResources |
|
string |
keyResource |
|
Returns
Type |
Description |
TlsEncryptionCredentials |
|
|
Edit this page
View Source
LoadPemResource(string)
Declaration
public static PemObject LoadPemResource(string path)
Parameters
Type |
Name |
Description |
string |
path |
|
Returns
Type |
Description |
PemObject |
|
|
Edit this page
View Source
LoadPrivateKeyResource(X509Certificate2)
Gets the private key of a .NET X509Certificate2 object
Declaration
public static AsymmetricKeyParameter LoadPrivateKeyResource(X509Certificate2 certificate)
Parameters
Type |
Name |
Description |
X509Certificate2 |
certificate |
Input certificate that contains a private key
|
Returns
Type |
Description |
AsymmetricKeyParameter |
Returns the private key contained in the certificate
|
|
Edit this page
View Source
LoadPrivateKeyResource(string)
Declaration
public static AsymmetricKeyParameter LoadPrivateKeyResource(string resource)
Parameters
Type |
Name |
Description |
string |
resource |
|
Returns
Type |
Description |
AsymmetricKeyParameter |
|
|
Edit this page
View Source
LoadSignerCredentials(TlsContext, Certificate, AsymmetricKeyParameter)
Declaration
public static TlsSignerCredentials LoadSignerCredentials(TlsContext context, Certificate certificate, AsymmetricKeyParameter privateKey)
Parameters
Type |
Name |
Description |
TlsContext |
context |
|
Certificate |
certificate |
|
AsymmetricKeyParameter |
privateKey |
|
Returns
Type |
Description |
TlsSignerCredentials |
|
|
Edit this page
View Source
LoadSignerCredentials(TlsContext, Certificate, AsymmetricKeyParameter, SignatureAndHashAlgorithm)
Declaration
public static TlsSignerCredentials LoadSignerCredentials(TlsContext context, Certificate certificate, AsymmetricKeyParameter privateKey, SignatureAndHashAlgorithm signatureAndHashAlgorithm)
Parameters
Type |
Name |
Description |
TlsContext |
context |
|
Certificate |
certificate |
|
AsymmetricKeyParameter |
privateKey |
|
SignatureAndHashAlgorithm |
signatureAndHashAlgorithm |
|
Returns
Type |
Description |
TlsSignerCredentials |
|
|
Edit this page
View Source
LoadSignerCredentials(TlsContext, IList, byte, Certificate, AsymmetricKeyParameter)
Declaration
public static TlsSignerCredentials? LoadSignerCredentials(TlsContext context, IList supportedSignatureAlgorithms, byte signatureAlgorithm, Certificate certificate, AsymmetricKeyParameter privateKey)
Parameters
Type |
Name |
Description |
TlsContext |
context |
|
IList |
supportedSignatureAlgorithms |
|
byte |
signatureAlgorithm |
|
Certificate |
certificate |
|
AsymmetricKeyParameter |
privateKey |
|
Returns
Type |
Description |
TlsSignerCredentials |
|
|
Edit this page
View Source
LoadSignerCredentials(TlsContext, IList, byte, string, string)
Declaration
public static TlsSignerCredentials? LoadSignerCredentials(TlsContext context, IList supportedSignatureAlgorithms, byte signatureAlgorithm, string certResource, string keyResource)
Parameters
Type |
Name |
Description |
TlsContext |
context |
|
IList |
supportedSignatureAlgorithms |
|
byte |
signatureAlgorithm |
|
string |
certResource |
|
string |
keyResource |
|
Returns
Type |
Description |
TlsSignerCredentials |
|
|
Edit this page
View Source
LoadSignerCredentials(TlsContext, string[], string)
Declaration
public static TlsSignerCredentials LoadSignerCredentials(TlsContext context, string[] certResources, string keyResource)
Parameters
Type |
Name |
Description |
TlsContext |
context |
|
string[] |
certResources |
|
string |
keyResource |
|
Returns
Type |
Description |
TlsSignerCredentials |
|
|
Edit this page
View Source
LoadSignerCredentials(TlsContext, string[], string, SignatureAndHashAlgorithm)
Declaration
public static TlsSignerCredentials LoadSignerCredentials(TlsContext context, string[] certResources, string keyResource, SignatureAndHashAlgorithm signatureAndHashAlgorithm)
Parameters
Type |
Name |
Description |
TlsContext |
context |
|
string[] |
certResources |
|
string |
keyResource |
|
SignatureAndHashAlgorithm |
signatureAndHashAlgorithm |
|
Returns
Type |
Description |
TlsSignerCredentials |
|
|
Edit this page
View Source
ToRSA(RsaPrivateCrtKeyParameters)
Declaration
public static RSA ToRSA(RsaPrivateCrtKeyParameters privKey)
Parameters
Type |
Name |
Description |
RsaPrivateCrtKeyParameters |
privKey |
|
Returns
|
Edit this page
View Source
ToRSAParameters(RsaPrivateCrtKeyParameters)
Converts a BouncyCastle RsaPrivateCrtKeyParameters to a .NET RSAParameters object.
Declaration
public static RSAParameters ToRSAParameters(RsaPrivateCrtKeyParameters privKey)
Parameters
Type |
Name |
Description |
RsaPrivateCrtKeyParameters |
privKey |
Input RSA private key parameters
|
Returns
Type |
Description |
RSAParameters |
Returns a new .NET RSAParameters object.
|