PcapPlusPlus  Next
pcpp::X509Certificate Class Reference

#include <X509Decoder.h>

Public Member Functions

X509Version getVersion () const
 
X509SerialNumber getSerialNumber () const
 
X509Name getIssuer () const
 
X509Name getSubject () const
 
X509Timestamp getNotBefore () const
 
X509Timestamp getNotAfter () const
 
X509Algorithm getPublicKeyAlgorithm () const
 
X509Key getPublicKey () const
 
X509Algorithm getSignatureAlgorithm () const
 
X509Key getSignature () const
 
size_t getExtensionCount () const
 
bool hasExtension (const X509ExtensionType &extensionType) const
 
std::vector< uint8_t > toDER () const
 
std::string toJson (int indent=-1) const
 
const X509Internal::X509CertificategetRawCertificate () const
 

Static Public Member Functions

static std::unique_ptr< X509CertificatefromDER (uint8_t *derData, size_t derDataLen, bool ownDerData=false)
 
static std::unique_ptr< X509CertificatefromDER (const std::string &derData)
 
static std::unique_ptr< X509CertificatefromDERFile (const std::string &derFileName)
 

Detailed Description

Represents an X.509 certificate

Member Function Documentation

◆ fromDER() [1/2]

static std::unique_ptr<X509Certificate> pcpp::X509Certificate::fromDER ( const std::string &  derData)
static

Creates an X509Certificate from a hex string containing DER-encoded data

Parameters
[in]derDataHex string containing DER-encoded certificate data
Returns
A unique pointer to the created X509Certificate
Exceptions
Anexception if the data is not a valid ASN.1 record

◆ fromDER() [2/2]

static std::unique_ptr<X509Certificate> pcpp::X509Certificate::fromDER ( uint8_t *  derData,
size_t  derDataLen,
bool  ownDerData = false 
)
static

Creates an X509Certificate from DER-encoded data

Parameters
[in]derDataPointer to the DER-encoded certificate data
[in]derDataLenLength of the DER-encoded data
[in]ownDerDataIf true, the certificate will take ownership of the data and free it when the certificate class is destructed
Returns
A unique pointer to the created X509Certificate
Exceptions
Anexception if the data is not a valid ASN.1 record

◆ fromDERFile()

static std::unique_ptr<X509Certificate> pcpp::X509Certificate::fromDERFile ( const std::string &  derFileName)
static

Creates an X509Certificate from a file containing DER-encoded data

Parameters
[in]derFileNamePath to the file containing DER-encoded certificate
Returns
A unique pointer to the created X509Certificate
Exceptions
Anexception if the file doesn't exist, cannot be read or contains invalid data

◆ getExtensionCount()

size_t pcpp::X509Certificate::getExtensionCount ( ) const

Gets the number of extensions in the certificate

Returns
The number of extensions

◆ getIssuer()

X509Name pcpp::X509Certificate::getIssuer ( ) const

Gets the issuer of the certificate

Returns
The certificate's issuer name

◆ getNotAfter()

X509Timestamp pcpp::X509Certificate::getNotAfter ( ) const

Gets the notAfter timestamp of the certificate's validity period

Returns
The notAfter timestamp

◆ getNotBefore()

X509Timestamp pcpp::X509Certificate::getNotBefore ( ) const

Gets the notBefore timestamp of the certificate's validity period

Returns
The notBefore timestamp

◆ getPublicKey()

X509Key pcpp::X509Certificate::getPublicKey ( ) const

Gets the public key from the certificate

Returns
The public key

◆ getPublicKeyAlgorithm()

X509Algorithm pcpp::X509Certificate::getPublicKeyAlgorithm ( ) const

Gets the public key algorithm used in the certificate

Returns
The public key algorithm

◆ getRawCertificate()

const X509Internal::X509Certificate* pcpp::X509Certificate::getRawCertificate ( ) const

Gets the raw internal certificate object

Returns
Pointer to the internal X509Certificate implementation

◆ getSerialNumber()

X509SerialNumber pcpp::X509Certificate::getSerialNumber ( ) const

Gets the serial number of the certificate

Returns
The certificate's serial number

◆ getSignature()

X509Key pcpp::X509Certificate::getSignature ( ) const

Gets the signature of the certificate

Returns
The certificate's signature

◆ getSignatureAlgorithm()

X509Algorithm pcpp::X509Certificate::getSignatureAlgorithm ( ) const

Gets the signature algorithm used to sign the certificate

Returns
The signature algorithm

◆ getSubject()

X509Name pcpp::X509Certificate::getSubject ( ) const

Gets the subject of the certificate

Returns
The certificate's subject name

◆ getVersion()

X509Version pcpp::X509Certificate::getVersion ( ) const

Gets the version of the certificate

Returns
The X509Version of the certificate

◆ hasExtension()

bool pcpp::X509Certificate::hasExtension ( const X509ExtensionType extensionType) const

Checks if the certificate has a specific extension

Parameters
[in]extensionTypeThe extension type to check for
Returns
true if the extension is present, false otherwise

◆ toDER()

std::vector<uint8_t> pcpp::X509Certificate::toDER ( ) const

Converts the certificate to DER-encoded format

Returns
A byte vector containing the DER-encoded data

◆ toJson()

std::string pcpp::X509Certificate::toJson ( int  indent = -1) const

Converts the certificate to a JSON string representation

Parameters
[in]indentNumber of spaces to use for indentation (-1 for no pretty printing)
Returns
A JSON string representation of the certificate