Show / Hide Table of Contents

Class DtlsUtils

Inheritance
System.Object
DtlsUtils
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: SIPSorcery.Net
Assembly: SIPSorcery.dll
Syntax
public class DtlsUtils

Fields

| Improve this Doc View Source

CERTIFICATE_COMMON_NAME

Common name to use for ephemeral DTSL certificates.

Declaration
public const string CERTIFICATE_COMMON_NAME = "WebRTC"
Field Value
Type Description
System.String
| Improve this Doc View Source

CERTIFICATE_VALIDITY_DAYS

The W3C WebRTC specification specifies certificate should be valid for 30 days https://www.w3.org/TR/webrtc/#methods-3.

Declaration
public const int CERTIFICATE_VALIDITY_DAYS = 30
Field Value
Type Description
System.Int32
| Improve this Doc View Source

CipherSuiteNames

Declaration
public static readonly Dictionary<int, string> CipherSuiteNames
Field Value
Type Description
System.Collections.Generic.Dictionary<System.Int32, System.String>
| Improve this Doc View Source

DEFAULT_RSA_KEY_SIZE

The RSA key size when generating random keys for self signed certificates.

Declaration
public const int DEFAULT_RSA_KEY_SIZE = 2048
Field Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

ConvertBouncyCert(X509Certificate, AsymmetricCipherKeyPair)

Declaration
public static X509Certificate2 ConvertBouncyCert(X509Certificate bouncyCert, AsymmetricCipherKeyPair keyPair)
Parameters
Type Name Description
Org.BouncyCastle.X509.X509Certificate bouncyCert
Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair keyPair
Returns
Type Description
System.Security.Cryptography.X509Certificates.X509Certificate2
Remarks

Plagiarised from https://github.com/CryptLink/CertBuilder/blob/master/CertBuilder.cs. NOTE: netstandard2.1+ and netcoreapp3.1+ have x509.CopyWithPrivateKey which will avoid the need to use the serialize/deserialize from pfx to get from bouncy castle to .NET Core X509 certificates.

| Improve this Doc View Source

CreatePrivateKeyResource(String)

Declaration
public static AsymmetricKeyParameter CreatePrivateKeyResource(string subjectName = "CN=root")
Parameters
Type Name Description
System.String subjectName
Returns
Type Description
Org.BouncyCastle.Crypto.AsymmetricKeyParameter
| Improve this Doc View Source

CreateSelfSignedEcdsaCert()

Declaration
public static (X509Certificate certificate, AsymmetricKeyParameter privateKey) CreateSelfSignedEcdsaCert()
Returns
Type Description
System.ValueTuple<Org.BouncyCastle.X509.X509Certificate, Org.BouncyCastle.Crypto.AsymmetricKeyParameter>
| Improve this Doc View Source

CreateSelfSignedEcdsaCert(String, String)

Declaration
public static (X509Certificate certificate, AsymmetricKeyParameter privateKey) CreateSelfSignedEcdsaCert(string subjectName, string issuerName)
Parameters
Type Name Description
System.String subjectName
System.String issuerName
Returns
Type Description
System.ValueTuple<Org.BouncyCastle.X509.X509Certificate, Org.BouncyCastle.Crypto.AsymmetricKeyParameter>
| Improve this Doc View Source

CreateSelfSignedRsaCert()

Declaration
public static (X509Certificate certificate, AsymmetricKeyParameter privateKey) CreateSelfSignedRsaCert()
Returns
Type Description
System.ValueTuple<Org.BouncyCastle.X509.X509Certificate, Org.BouncyCastle.Crypto.AsymmetricKeyParameter>
| Improve this Doc View Source

CreateSelfSignedRsaCert(String, String, AsymmetricKeyParameter)

Declaration
public static (X509Certificate certificate, AsymmetricKeyParameter privateKey) CreateSelfSignedRsaCert(string subjectName, string issuerName, AsymmetricKeyParameter issuerPrivateKey)
Parameters
Type Name Description
System.String subjectName
System.String issuerName
Org.BouncyCastle.Crypto.AsymmetricKeyParameter issuerPrivateKey
Returns
Type Description
System.ValueTuple<Org.BouncyCastle.X509.X509Certificate, Org.BouncyCastle.Crypto.AsymmetricKeyParameter>
| Improve this Doc View Source

CreateSelfSignedTlsCert(Boolean)

Declaration
public static (Certificate certificate, AsymmetricKeyParameter privateKey) CreateSelfSignedTlsCert(bool useRsa = false)
Parameters
Type Name Description
System.Boolean useRsa
Returns
Type Description
System.ValueTuple<Org.BouncyCastle.Crypto.Tls.Certificate, Org.BouncyCastle.Crypto.AsymmetricKeyParameter>
| Improve this Doc View Source

CreateSelfSignedTlsCert(String, String, AsymmetricKeyParameter, Boolean)

Declaration
public static (Certificate certificate, AsymmetricKeyParameter privateKey) CreateSelfSignedTlsCert(string subjectName, string issuerName, AsymmetricKeyParameter issuerPrivateKey, bool useRsa)
Parameters
Type Name Description
System.String subjectName
System.String issuerName
Org.BouncyCastle.Crypto.AsymmetricKeyParameter issuerPrivateKey
System.Boolean useRsa
Returns
Type Description
System.ValueTuple<Org.BouncyCastle.Crypto.Tls.Certificate, Org.BouncyCastle.Crypto.AsymmetricKeyParameter>
| Improve this Doc View Source

DigestOf(IDigest, Byte[])

Declaration
public static byte[] DigestOf(IDigest dAlg, byte[] input)
Parameters
Type Name Description
Org.BouncyCastle.Crypto.IDigest dAlg
System.Byte[] input
Returns
Type Description
System.Byte[]
| Improve this Doc View Source

ExportToDerBase64(Certificate)

Declaration
public static string ExportToDerBase64(Certificate certificate)
Parameters
Type Name Description
Org.BouncyCastle.Crypto.Tls.Certificate certificate
Returns
Type Description
System.String
| Improve this Doc View Source

Fingerprint(X509CertificateStructure)

Declaration
public static RTCDtlsFingerprint Fingerprint(X509CertificateStructure c)
Parameters
Type Name Description
Org.BouncyCastle.Asn1.X509.X509CertificateStructure c
Returns
Type Description
RTCDtlsFingerprint
| Improve this Doc View Source

Fingerprint(Certificate)

Declaration
public static RTCDtlsFingerprint Fingerprint(Certificate certificateChain)
Parameters
Type Name Description
Org.BouncyCastle.Crypto.Tls.Certificate certificateChain
Returns
Type Description
RTCDtlsFingerprint
| Improve this Doc View Source

Fingerprint(X509Certificate)

Declaration
public static RTCDtlsFingerprint Fingerprint(X509Certificate certificate)
Parameters
Type Name Description
Org.BouncyCastle.X509.X509Certificate certificate
Returns
Type Description
RTCDtlsFingerprint
| Improve this Doc View Source

Fingerprint(X509Certificate2)

Declaration
public static RTCDtlsFingerprint Fingerprint(X509Certificate2 certificate)
Parameters
Type Name Description
System.Security.Cryptography.X509Certificates.X509Certificate2 certificate
Returns
Type Description
RTCDtlsFingerprint
| Improve this Doc View Source

Fingerprint(String, X509CertificateStructure)

Declaration
public static RTCDtlsFingerprint Fingerprint(string hashAlgorithm, X509CertificateStructure c)
Parameters
Type Name Description
System.String hashAlgorithm
Org.BouncyCastle.Asn1.X509.X509CertificateStructure c
Returns
Type Description
RTCDtlsFingerprint
| Improve this Doc View Source

Fingerprint(String, X509Certificate2)

Declaration
public static RTCDtlsFingerprint Fingerprint(string hashAlgorithm, X509Certificate2 certificate)
Parameters
Type Name Description
System.String hashAlgorithm
System.Security.Cryptography.X509Certificates.X509Certificate2 certificate
Returns
Type Description
RTCDtlsFingerprint
| Improve this Doc View Source

GetFriendlyNameFromOid(String)

Declaration
public static string GetFriendlyNameFromOid(string oid)
Parameters
Type Name Description
System.String oid
Returns
Type Description
System.String
| Improve this Doc View Source

GetSignatureAlgorithm(X509CertificateStructure)

Declaration
public static string GetSignatureAlgorithm(X509CertificateStructure certificate)
Parameters
Type Name Description
Org.BouncyCastle.Asn1.X509.X509CertificateStructure certificate
Returns
Type Description
System.String
| Improve this Doc View Source

GetSignatureAlgorithm(Certificate)

Declaration
public static string GetSignatureAlgorithm(Certificate certificateChain)
Parameters
Type Name Description
Org.BouncyCastle.Crypto.Tls.Certificate certificateChain
Returns
Type Description
System.String
| Improve this Doc 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
System.String hashAlgorithm

The hash algorithm to check.

Returns
Type Description
System.Boolean
| Improve this Doc View Source

LoadAgreementCredentials(TlsContext, Certificate, AsymmetricKeyParameter)

Declaration
public static TlsAgreementCredentials LoadAgreementCredentials(TlsContext context, Certificate certificate, AsymmetricKeyParameter privateKey)
Parameters
Type Name Description
Org.BouncyCastle.Crypto.Tls.TlsContext context
Org.BouncyCastle.Crypto.Tls.Certificate certificate
Org.BouncyCastle.Crypto.AsymmetricKeyParameter privateKey
Returns
Type Description
Org.BouncyCastle.Crypto.Tls.TlsAgreementCredentials
| Improve this Doc View Source

LoadAgreementCredentials(TlsContext, String[], String)

Declaration
public static TlsAgreementCredentials LoadAgreementCredentials(TlsContext context, string[] certResources, string keyResource)
Parameters
Type Name Description
Org.BouncyCastle.Crypto.Tls.TlsContext context
System.String[] certResources
System.String keyResource
Returns
Type Description
Org.BouncyCastle.Crypto.Tls.TlsAgreementCredentials
| Improve this Doc View Source

LoadCertificateChain(X509Certificate2)

Declaration
public static Certificate LoadCertificateChain(X509Certificate2 certificate)
Parameters
Type Name Description
System.Security.Cryptography.X509Certificates.X509Certificate2 certificate
Returns
Type Description
Org.BouncyCastle.Crypto.Tls.Certificate
| Improve this Doc View Source

LoadCertificateChain(X509Certificate2[])

Declaration
public static Certificate LoadCertificateChain(X509Certificate2[] certificates)
Parameters
Type Name Description
System.Security.Cryptography.X509Certificates.X509Certificate2[] certificates
Returns
Type Description
Org.BouncyCastle.Crypto.Tls.Certificate
| Improve this Doc View Source

LoadCertificateChain(String[])

Declaration
public static Certificate LoadCertificateChain(string[] resources)
Parameters
Type Name Description
System.String[] resources
Returns
Type Description
Org.BouncyCastle.Crypto.Tls.Certificate
| Improve this Doc View Source

LoadCertificateResource(X509Certificate2)

Declaration
public static X509CertificateStructure LoadCertificateResource(X509Certificate2 certificate)
Parameters
Type Name Description
System.Security.Cryptography.X509Certificates.X509Certificate2 certificate
Returns
Type Description
Org.BouncyCastle.Asn1.X509.X509CertificateStructure
| Improve this Doc View Source

LoadCertificateResource(String)

Declaration
public static X509CertificateStructure LoadCertificateResource(string resource)
Parameters
Type Name Description
System.String resource
Returns
Type Description
Org.BouncyCastle.Asn1.X509.X509CertificateStructure
| Improve this Doc View Source

LoadEncryptionCredentials(TlsContext, Certificate, AsymmetricKeyParameter)

Declaration
public static TlsEncryptionCredentials LoadEncryptionCredentials(TlsContext context, Certificate certificate, AsymmetricKeyParameter privateKey)
Parameters
Type Name Description
Org.BouncyCastle.Crypto.Tls.TlsContext context
Org.BouncyCastle.Crypto.Tls.Certificate certificate
Org.BouncyCastle.Crypto.AsymmetricKeyParameter privateKey
Returns
Type Description
Org.BouncyCastle.Crypto.Tls.TlsEncryptionCredentials
| Improve this Doc View Source

LoadEncryptionCredentials(TlsContext, String[], String)

Declaration
public static TlsEncryptionCredentials LoadEncryptionCredentials(TlsContext context, string[] certResources, string keyResource)
Parameters
Type Name Description
Org.BouncyCastle.Crypto.Tls.TlsContext context
System.String[] certResources
System.String keyResource
Returns
Type Description
Org.BouncyCastle.Crypto.Tls.TlsEncryptionCredentials
| Improve this Doc View Source

LoadPemResource(String)

Declaration
public static PemObject LoadPemResource(string path)
Parameters
Type Name Description
System.String path
Returns
Type Description
Org.BouncyCastle.Utilities.IO.Pem.PemObject
| Improve this Doc View Source

LoadPrivateKeyResource(X509Certificate2)

Declaration
public static AsymmetricKeyParameter LoadPrivateKeyResource(X509Certificate2 certificate)
Parameters
Type Name Description
System.Security.Cryptography.X509Certificates.X509Certificate2 certificate
Returns
Type Description
Org.BouncyCastle.Crypto.AsymmetricKeyParameter
| Improve this Doc View Source

LoadPrivateKeyResource(String)

Declaration
public static AsymmetricKeyParameter LoadPrivateKeyResource(string resource)
Parameters
Type Name Description
System.String resource
Returns
Type Description
Org.BouncyCastle.Crypto.AsymmetricKeyParameter
| Improve this Doc View Source

LoadSignerCredentials(TlsContext, Certificate, AsymmetricKeyParameter)

Declaration
public static TlsSignerCredentials LoadSignerCredentials(TlsContext context, Certificate certificate, AsymmetricKeyParameter privateKey)
Parameters
Type Name Description
Org.BouncyCastle.Crypto.Tls.TlsContext context
Org.BouncyCastle.Crypto.Tls.Certificate certificate
Org.BouncyCastle.Crypto.AsymmetricKeyParameter privateKey
Returns
Type Description
Org.BouncyCastle.Crypto.Tls.TlsSignerCredentials
| Improve this Doc View Source

LoadSignerCredentials(TlsContext, Certificate, AsymmetricKeyParameter, SignatureAndHashAlgorithm)

Declaration
public static TlsSignerCredentials LoadSignerCredentials(TlsContext context, Certificate certificate, AsymmetricKeyParameter privateKey, SignatureAndHashAlgorithm signatureAndHashAlgorithm)
Parameters
Type Name Description
Org.BouncyCastle.Crypto.Tls.TlsContext context
Org.BouncyCastle.Crypto.Tls.Certificate certificate
Org.BouncyCastle.Crypto.AsymmetricKeyParameter privateKey
Org.BouncyCastle.Crypto.Tls.SignatureAndHashAlgorithm signatureAndHashAlgorithm
Returns
Type Description
Org.BouncyCastle.Crypto.Tls.TlsSignerCredentials
| Improve this Doc 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
Org.BouncyCastle.Crypto.Tls.TlsContext context
System.Collections.IList supportedSignatureAlgorithms
System.Byte signatureAlgorithm
Org.BouncyCastle.Crypto.Tls.Certificate certificate
Org.BouncyCastle.Crypto.AsymmetricKeyParameter privateKey
Returns
Type Description
Org.BouncyCastle.Crypto.Tls.TlsSignerCredentials
| Improve this Doc 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
Org.BouncyCastle.Crypto.Tls.TlsContext context
System.Collections.IList supportedSignatureAlgorithms
System.Byte signatureAlgorithm
System.String certResource
System.String keyResource
Returns
Type Description
Org.BouncyCastle.Crypto.Tls.TlsSignerCredentials
| Improve this Doc View Source

LoadSignerCredentials(TlsContext, String[], String)

Declaration
public static TlsSignerCredentials LoadSignerCredentials(TlsContext context, string[] certResources, string keyResource)
Parameters
Type Name Description
Org.BouncyCastle.Crypto.Tls.TlsContext context
System.String[] certResources
System.String keyResource
Returns
Type Description
Org.BouncyCastle.Crypto.Tls.TlsSignerCredentials
| Improve this Doc View Source

LoadSignerCredentials(TlsContext, String[], String, SignatureAndHashAlgorithm)

Declaration
public static TlsSignerCredentials LoadSignerCredentials(TlsContext context, string[] certResources, string keyResource, SignatureAndHashAlgorithm signatureAndHashAlgorithm)
Parameters
Type Name Description
Org.BouncyCastle.Crypto.Tls.TlsContext context
System.String[] certResources
System.String keyResource
Org.BouncyCastle.Crypto.Tls.SignatureAndHashAlgorithm signatureAndHashAlgorithm
Returns
Type Description
Org.BouncyCastle.Crypto.Tls.TlsSignerCredentials
| Improve this Doc View Source

ToRSA(RsaPrivateCrtKeyParameters)

This method and the related ones have been copied from the BouncyCode DotNetUtilities class due to https://github.com/bcgit/bc-csharp/issues/160 which prevents the original version from working on non-Windows platforms.

Declaration
public static RSA ToRSA(RsaPrivateCrtKeyParameters privKey)
Parameters
Type Name Description
Org.BouncyCastle.Crypto.Parameters.RsaPrivateCrtKeyParameters privKey
Returns
Type Description
System.Security.Cryptography.RSA
| Improve this Doc View Source

ToRSAParameters(RsaPrivateCrtKeyParameters)

Declaration
public static RSAParameters ToRSAParameters(RsaPrivateCrtKeyParameters privKey)
Parameters
Type Name Description
Org.BouncyCastle.Crypto.Parameters.RsaPrivateCrtKeyParameters privKey
Returns
Type Description
System.Security.Cryptography.RSAParameters

Extension Methods

JSONWriter.ToJson(Object)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX