Table of Contents

Class X509Certificate

Namespace
Org.BouncyCastle.X509
Assembly
BouncyCastle.Cryptography.dll

An Object representing an X509 Certificate. Has static methods for loading Certificates encoded in many forms that return X509Certificate Objects.

public class X509Certificate : X509ExtensionBase, IX509Extension
Inheritance
X509Certificate
Implements
Inherited Members

Constructors

X509Certificate()

protected X509Certificate()

X509Certificate(X509CertificateStructure)

public X509Certificate(X509CertificateStructure c)

Parameters

c X509CertificateStructure

X509Certificate(byte[])

public X509Certificate(byte[] certData)

Parameters

certData byte[]

Properties

CertificateStructure

public virtual X509CertificateStructure CertificateStructure { get; }

Property Value

X509CertificateStructure

IsValidNow

Return true if the current time is within the start and end times nominated on the certificate.

public virtual bool IsValidNow { get; }

Property Value

bool

true id certificate is valid for the current time.

IssuerDN

Get the Issuer Distinguished Name. (Who signed the certificate.)

public virtual X509Name IssuerDN { get; }

Property Value

X509Name

And X509Object containing name and value pairs.

IssuerUniqueID

Get the issuers UID.

public virtual DerBitString IssuerUniqueID { get; }

Property Value

DerBitString

A DerBitString.

NotAfter

The time that this certificate is valid up to.

public virtual DateTime NotAfter { get; }

Property Value

DateTime

A DateTime object representing that time in the local time zone.

NotBefore

The time that this certificate is valid from.

public virtual DateTime NotBefore { get; }

Property Value

DateTime

A DateTime object representing that time in the local time zone.

SerialNumber

Return a BigInteger containing the serial number.

public virtual BigInteger SerialNumber { get; }

Property Value

BigInteger

The Serial number.

SigAlgName

A meaningful version of the Signature Algorithm. (e.g. SHA1WITHRSA)

public virtual string SigAlgName { get; }

Property Value

string

A string representing the signature algorithm.

SigAlgOid

Get the Signature Algorithms Object ID.

public virtual string SigAlgOid { get; }

Property Value

string

A string containg a '.' separated object id.

SignatureAlgorithm

The signature algorithm.

public virtual AlgorithmIdentifier SignatureAlgorithm { get; }

Property Value

AlgorithmIdentifier

SubjectDN

Get the subject of this certificate.

public virtual X509Name SubjectDN { get; }

Property Value

X509Name

An X509Name object containing name and value pairs.

SubjectPublicKeyInfo

Return the plain SubjectPublicKeyInfo that holds the encoded public key.

public virtual SubjectPublicKeyInfo SubjectPublicKeyInfo { get; }

Property Value

SubjectPublicKeyInfo

SubjectUniqueID

Get the subjects UID.

public virtual DerBitString SubjectUniqueID { get; }

Property Value

DerBitString

A DerBitString.

TbsCertificate

public virtual TbsCertificateStructure TbsCertificate { get; }

Property Value

TbsCertificateStructure

Version

Return the certificate's version.

public virtual int Version { get; }

Property Value

int

An integer whose value Equals the version of the cerficate.

Methods

CheckSignature(IVerifierFactory)

protected virtual void CheckSignature(IVerifierFactory verifier)

Parameters

verifier IVerifierFactory

CheckSignatureValid(IVerifierFactory)

protected virtual bool CheckSignatureValid(IVerifierFactory verifier)

Parameters

verifier IVerifierFactory

Returns

bool

CheckValidity()

Checks if the current date is within certificate's validity period.

public virtual void CheckValidity()

CheckValidity(DateTime)

Checks if the given date is within certificate's validity period.

public virtual void CheckValidity(DateTime time)

Parameters

time DateTime

Exceptions

CertificateExpiredException

if the certificate is expired by given date

CertificateNotYetValidException

if the certificate is not yet valid on given date

Equals(object)

Determines whether the specified object is equal to the current object.

public override bool Equals(object other)

Parameters

other object

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetAlternativeNameExtension(DerObjectIdentifier)

protected virtual GeneralNames GetAlternativeNameExtension(DerObjectIdentifier oid)

Parameters

oid DerObjectIdentifier

Returns

GeneralNames

GetAlternativeNames(DerObjectIdentifier)

protected virtual IList<IList<object>> GetAlternativeNames(DerObjectIdentifier oid)

Parameters

oid DerObjectIdentifier

Returns

IList<IList<object>>

GetBasicConstraints()

public virtual int GetBasicConstraints()

Returns

int

GetEncoded()

Return the DER encoding of this certificate.

public virtual byte[] GetEncoded()

Returns

byte[]

A byte array containing the DER encoding of this certificate.

Exceptions

CertificateEncodingException

If there is an error encoding the certificate.

GetExtendedKeyUsage()

public virtual IList<DerObjectIdentifier> GetExtendedKeyUsage()

Returns

IList<DerObjectIdentifier>

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

GetIssuerAlternativeNameExtension()

public virtual GeneralNames GetIssuerAlternativeNameExtension()

Returns

GeneralNames

GetIssuerAlternativeNames()

public virtual IList<IList<object>> GetIssuerAlternativeNames()

Returns

IList<IList<object>>

GetKeyUsage()

Get a key usage guidlines.

public virtual bool[] GetKeyUsage()

Returns

bool[]

GetPublicKey()

Get the public key of the subject of the certificate.

public virtual AsymmetricKeyParameter GetPublicKey()

Returns

AsymmetricKeyParameter

The public key parameters.

GetSigAlgParams()

Get the signature algorithms parameters. (EG DSA Parameters)

public virtual byte[] GetSigAlgParams()

Returns

byte[]

A byte array containing the Der encoded version of the parameters or null if there are none.

GetSignature()

The signature.

public virtual byte[] GetSignature()

Returns

byte[]

A byte array containg the signature of the certificate.

GetSubjectAlternativeNameExtension()

public virtual GeneralNames GetSubjectAlternativeNameExtension()

Returns

GeneralNames

GetSubjectAlternativeNames()

public virtual IList<IList<object>> GetSubjectAlternativeNames()

Returns

IList<IList<object>>

GetTbsCertificate()

Return the Der encoded TbsCertificate data. This is the certificate component less the signature. To Get the whole certificate call the GetEncoded() member.

public virtual byte[] GetTbsCertificate()

Returns

byte[]

A byte array containing the Der encoded Certificate component.

GetX509Extensions()

protected override X509Extensions GetX509Extensions()

Returns

X509Extensions

IsAlternativeSignatureValid(AsymmetricKeyParameter)

public virtual bool IsAlternativeSignatureValid(AsymmetricKeyParameter publicKey)

Parameters

publicKey AsymmetricKeyParameter

Returns

bool

IsAlternativeSignatureValid(IVerifierFactoryProvider)

public virtual bool IsAlternativeSignatureValid(IVerifierFactoryProvider verifierProvider)

Parameters

verifierProvider IVerifierFactoryProvider

Returns

bool

IsSignatureValid(AsymmetricKeyParameter)

public virtual bool IsSignatureValid(AsymmetricKeyParameter key)

Parameters

key AsymmetricKeyParameter

Returns

bool

IsSignatureValid(IVerifierFactoryProvider)

public virtual bool IsSignatureValid(IVerifierFactoryProvider verifierProvider)

Parameters

verifierProvider IVerifierFactoryProvider

Returns

bool

IsValid(DateTime)

Return true if the nominated time is within the start and end times nominated on the certificate.

public virtual bool IsValid(DateTime time)

Parameters

time DateTime

The time to test validity against.

Returns

bool

True if certificate is valid for nominated time.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Verify(AsymmetricKeyParameter)

Verify the certificate's signature using the nominated public key.

public virtual void Verify(AsymmetricKeyParameter key)

Parameters

key AsymmetricKeyParameter

An appropriate public key parameter object, RsaPublicKeyParameters, DsaPublicKeyParameters or ECDsaPublicKeyParameters

Exceptions

Exception

If key submitted is not of the above nominated types.

Verify(IVerifierFactoryProvider)

Verify the certificate's signature using a verifier created using the passed in verifier provider.

public virtual void Verify(IVerifierFactoryProvider verifierProvider)

Parameters

verifierProvider IVerifierFactoryProvider

An appropriate provider for verifying the certificate's signature.

Exceptions

Exception

If verifier provider is not appropriate or the certificate signature algorithm is invalid.

VerifyAltSignature(IVerifierFactoryProvider)

Verify the certificate's alternative signature using a verifier created using the passed in verifier provider.

public virtual void VerifyAltSignature(IVerifierFactoryProvider verifierProvider)

Parameters

verifierProvider IVerifierFactoryProvider

An appropriate provider for verifying the certificate's alternative signature.

Exceptions

Exception

If verifier provider is not appropriate or the certificate alternative signature algorithm is invalid.