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
X509Certificate(byte[])
public X509Certificate(byte[] certData)
Parameters
certDatabyte[]
Properties
CertificateStructure
public virtual X509CertificateStructure CertificateStructure { get; }
Property Value
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
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
SubjectUniqueID
Get the subjects UID.
public virtual DerBitString SubjectUniqueID { get; }
Property Value
- DerBitString
A DerBitString.
TbsCertificate
public virtual TbsCertificateStructure TbsCertificate { get; }
Property Value
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
verifierIVerifierFactory
CheckSignatureValid(IVerifierFactory)
protected virtual bool CheckSignatureValid(IVerifierFactory verifier)
Parameters
verifierIVerifierFactory
Returns
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
timeDateTime
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
otherobject
Returns
GetAlternativeNameExtension(DerObjectIdentifier)
protected virtual GeneralNames GetAlternativeNameExtension(DerObjectIdentifier oid)
Parameters
Returns
GetAlternativeNames(DerObjectIdentifier)
protected virtual IList<IList<object>> GetAlternativeNames(DerObjectIdentifier oid)
Parameters
Returns
GetBasicConstraints()
public virtual int GetBasicConstraints()
Returns
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
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
GetIssuerAlternativeNames()
public virtual IList<IList<object>> GetIssuerAlternativeNames()
Returns
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
GetSubjectAlternativeNames()
public virtual IList<IList<object>> GetSubjectAlternativeNames()
Returns
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
IsAlternativeSignatureValid(AsymmetricKeyParameter)
public virtual bool IsAlternativeSignatureValid(AsymmetricKeyParameter publicKey)
Parameters
publicKeyAsymmetricKeyParameter
Returns
IsAlternativeSignatureValid(IVerifierFactoryProvider)
public virtual bool IsAlternativeSignatureValid(IVerifierFactoryProvider verifierProvider)
Parameters
verifierProviderIVerifierFactoryProvider
Returns
IsSignatureValid(AsymmetricKeyParameter)
public virtual bool IsSignatureValid(AsymmetricKeyParameter key)
Parameters
Returns
IsSignatureValid(IVerifierFactoryProvider)
public virtual bool IsSignatureValid(IVerifierFactoryProvider verifierProvider)
Parameters
verifierProviderIVerifierFactoryProvider
Returns
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
timeDateTimeThe 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
keyAsymmetricKeyParameterAn 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
verifierProviderIVerifierFactoryProviderAn 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
verifierProviderIVerifierFactoryProviderAn 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.