Click or drag to resize

TlsCertificate Class

Holds the public and private parts of a TLS certificate.
Inheritance Hierarchy
SystemObject
  Neon.CryptographyTlsCertificate

Namespace:  Neon.Cryptography
Assembly:  Neon.Cryptography (in Neon.Cryptography.dll) Version: 2.2.0
Syntax
public class TlsCertificate

The TlsCertificate type exposes the following members.

Constructors
  NameDescription
Public methodTlsCertificate
Constructs an uninitialized certificate.
Public methodTlsCertificate(String)
Constructs an instance by parsing the combined site certificate, any intermediate certificates followed by the private key as PEM encoded text.
Public methodTlsCertificate(String, String)
Constructs an instance by parsing the certificate and private key PEM encoded text passed.
Top
Properties
  NameDescription
Public propertyCertPem
The public certificate as PEM encoded text.
Public propertyCertPemNormalized
The public certificate as PEM encoded text normalized with Linux-style line endings.
Public propertyCombinedPem
Returns the combined certificate and private key as PEM encoded text.
Public propertyCombinedPemNormalized
Returns the combined certificate and private key as PEM encoded text normalized with Linux-style line endings for HAProxy compatability.
Public propertyFriendlyName

The friendly name for the certificate.

Note Note
This property was added for convienence and is not loaded from the certificate data. You may set this to whatever you wish.
Public propertyHostNames
Returns the DNS hostnames covered by the certificate as a comma separated string.
Public propertyHosts
The DNS hostnames covered by the certificate. This may be a single or wildcard hostname extracted from the certificate's Common Name or multiple hostname extracted from the Subject Alternative Name from a SAN certificate. This list will be null or empty if the hostname(s) are unknown.
Public propertyKeyPem
The private key as PEM encoded text or null if the private key is not present.
Public propertyKeyPemNormalized
The private key as PEM encoded text normalized with Linux-style line endings or null if the private key is not present.
Public propertyThumbprint
The certificate thumbprint.
Public propertyValidFrom
The date when the certificate becomes valid (or null).
Public propertyValidUntil
The date when the certificate expires (or null).
Top
Methods
  NameDescription
Public methodClone
Returns a deep copy of the instance.
Public methodStatic memberCreateSelfSigned(IEnumerableString, Int32, Int32, String, String)
Generates a self-signed certificate for arbitrary hostnames, possibly including hostnames with wildcards.
Public methodStatic memberCreateSelfSigned(String, Int32, Int32, Wildcard, String, String)
Generates a self-signed certificate for a hostname and/or a wildcarded hostname.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodStatic memberFromPemParts
Constructs an instance by parsing the certificate and private key PEM encoded parts passed.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIsValidDate
Determines whether the certificate is valid for the current or an optionally a specified date.
Public methodIsValidHost
Determines whether the certificate is valid for a hostname.
Public methodStatic memberLoad(String)
Loads a combined public certificate and private key from a PEM encoded text file.
Public methodStatic memberLoad(String, String)
Loads a combined public certificate and private key from two PEM encoded files.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodStatic memberNormalizePem
Normalizes PEM encoded text to have Linux style (LF) line endings.
Public methodParse
Attempts to parse the certificate details.
Public methodStatic memberParse(String)
Parses a certificate and private key from PEM encoded text.
Public methodParseCertUtil
Extracts certificate properties such as ValidFrom, ValidUntil, and Hosts from the dump output from the Windows CertUtil.exe tool (e.g. via certutil -dump cert.pem).
Public methodParseOpenSsl
Extracts certificate properties such as ValidFrom, ValidUntil, and Hosts from the dump output from the OpenSSL tool (e.g. via openssl x509 -in cert.pem -text).
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodToX509

Converts the TlsCertificate into a X509Certificate2.

Note Note
The certificate return will not include the TlsCertificate's private key if there is one.
Public methodStatic memberTryParse
Attempts to parse a certificate and private key from PEM encoded text.
Public methodStatic memberValidate
Validates a certificate file.
Top
Remarks

This class follows the HAProxy convention of allowing the PEM encoded public certificate and private key to be encoded into a single text file by simply concatenating the public certificate with the private key, certificate first.

Note Note
The certificate part must include any intermediate certificates issues by the certificate authority after the certificate and before the private key.
See Also