![]() |
Gray C++ Libraries
0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
|
#include <cX509Crt.h>
Public Member Functions | |
cX509Crt () noexcept | |
~cX509Crt () | |
void | put_SerialNumber (const cBigUnsigned &serial) |
virtual HRESULT | GetDescription (StrBuilder &s, const char *prefix) const override |
X509_Verify_t | VerifyKeyUsage (X509_KeyUsage_TYPE usage, bool bEndpointIsServer) const |
virtual HRESULT | ReadFromDER (const BYTE *pBuffer, size_t buflen) override |
virtual HRESULT | ReadFromUnk (const BYTE *pBuffer, size_t buflen) override |
HRESULT | ReadCrtsFromDir (const FILECHAR_t *pszCertDir) |
X509_Verify_t | VerifyCrl (const cX509Crt *pCrtCA, const cX509Crl *pCrl) const |
HRESULT | VerifyCrt (const cX509Crt *pCrtCA, const cX509Crl *pCrl, const char *cn, OUT X509_Verify_t &rFlags, IX509VerifyCert *pVerifyCert) const |
virtual void | SetEmptyX () override |
HRESULT | WriteToDER (BYTE *pBuffer, size_t size, const cASNSets &extensions2, const cKeyWrap &rIssuerKey, IRandomNoise *pRandom) |
HRESULT | WriteToPEM (char *pOut, StrLen_t size, const cASNSets &extensions2, const cKeyWrap &rIssuerKey, IRandomNoise *pRandom) |
UNITTEST_FRIEND (cX509Crt) | |
![]() | |
cX509Common () noexcept | |
virtual | ~cX509Common () |
bool | isEmptyX () const noexcept |
HRESULT | ReadSigAlg (cASNReader &r1, cASNBuf &sig_params) |
HRESULT | GetSigAlgStr (StrBuilder &s) const |
HRESULT | ReadFromFile (const FILECHAR_t *pszFilePath) |
UNITTEST_FRIEND (cX509Common) | |
![]() | |
cRefBase (int iRefCount=0) noexcept | |
virtual | ~cRefBase () |
int | get_RefCount () const noexcept |
HASHCODE_t | get_HashCode () const noexcept |
STDMETHOD_ (HASHCODE_t, get_HashCodeX)() const noexcept | |
virtual void | onFinalRelease () |
bool | isValidObj () const noexcept |
STDMETHOD_ (ULONG, AddRef)(void) override | |
STDMETHOD_ (ULONG, Release)(void) override | |
STDMETHOD() | QueryInterface (const IID &riid, void __RPC_FAR *__RPC_FAR *ppvObject) override |
void | IncRefCount () |
void | DecRefCount () |
bool | isStaticConstruct () const noexcept |
void | StaticConstruct () |
void | StaticDestruct () |
bool | isDestructing () noexcept |
void | SetDestructing () |
Static Public Member Functions | |
static HRESULT | GetVerifyStatusText (StrBuilder &s, const char *prefix, X509_Verify_t flags) |
![]() | |
static HRESULT | ReturnError (HRESULT hRes) noexcept |
static X509_Verify_t | X509_VerifySet (X509_Verify_t f1, X509_Verify_t f2) noexcept |
static StrLen_t GRAYCALL | GetSerialStr (StrBuilder &s, const cASNBuf &serial) |
Public Attributes | |
cASNBufAlloc | m_SerialNumber |
Unique binary id for certificate issued by a specific CA. CertificateSerialNumber (RFC5280 size max = 32) cBigUnsigned ASN_INTEGER. More... | |
cASNSets | m_issuer |
The parsed issuer (named information object). e.g. "CN=SDF ???". More... | |
cTimeUnits | m_tValidFrom |
Start time of certificate validity. More... | |
cTimeUnits | m_tValidTo |
End time of certificate validity. More... | |
cASNBuf | m_subject_raw |
for use in SSL_CERTIFICATE_REQUEST More... | |
cASNSets | m_subject |
The parsed m_subject_raw (named information object). More... | |
cKeyWrap | m_SubjectPublicKey |
Container for the public key context. "SubjectPublicKeyInfo". More... | |
cASNBuf | m_issuer_id |
Optional X.509 v2/v3 issuer unique identifier. UNUSED. X509_EXT_AUTHORITY_KEY_IDENTIFIER/OID_AUTHORITY_KEY_IDENTIFIER ? More... | |
cASNBuf | m_subject_id |
Optional X.509 v2/v3 subject unique identifier. UNUSED. X509_EXT_SUBJECT_KEY_IDENTIFIER/OID_SUBJECT_KEY_IDENTIFIER ? More... | |
cX509CrtExt | m_Ext |
optional extensions. AKA ExtensionList. More... | |
cRefPtr< cX509Crt > | m_pNextCrt |
Next certificate in the CA-chain. More... | |
![]() | |
cHeapBlock | m_raw |
The raw certificate data (ReadFromDer1). cASNBuf pointers can point into this. More... | |
cASNBuf | m_RawSigned |
The raw certificate body (in m_raw)(ReadFromDer1). The part that is To Be Signed. Precedes m_nVersion. More... | |
int | m_nVersion |
1,2,3. 0 = unused. X509_CRT_VERSION_TYPE or CRL version More... | |
cASNBuf | m_SignOID1 |
Signature algorithm OID, e.g. "sha1RSA" for ReadSigAlg() More... | |
cKeySigAlg | m_SigAlg |
How to sign with m_SignOID1. More... | |
cASNBuf | m_SignBuffer |
cNewPtr< cKeyRSASignOptions > | m_pRSASignOptions |
Signature options to be passed to VerifySignatureExt(), e.g. for RSASSA-PSS SSL_Key_RSASSA_PSS. More... | |
Static Public Attributes | |
static const char * | k_pszPEM = "CERTIFICATE" |
"CERTIFICATE" More... | |
![]() | |
static const int | k_MAX_INTERMEDIATE_CA = 8 |
Structures and functions for parsing and writing X.509 certificates Container for an X.509 certificate. The certificate may be chained. The raw certificate data (DER). The X.509 CRT version. (1=v1, 2=v2, 3=v3)
|
inlinenoexcept |
|
inline |
|
overridevirtual |
Implements GrayLib::cX509Common.
|
static |
Returns an informational string about the verification status of a certificate.
Get error description for X509_Verify_t. StrBuilder For unit test.
|
inline |
Set the serial number for a Certificate.
HRESULT GrayLib::cX509Crt::ReadCrtsFromDir | ( | const FILECHAR_t * | pszCertDir | ) |
Load one or more certificate files from a path and add them to the chained list. Parses permissively. If some certificates can be parsed, the result is the number of failed certificates it encountered. If none complete correctly, the first error is returned.
|
overridevirtual |
X509_FORMAT_DER Parse one X.509 certificate in DER format from a buffer and add them to a chained list Check for valid input
Implements GrayLib::cX509Common.
|
overridevirtual |
Parse one or more PEM (or DER) certificates from a buffer and add them to the chained list .
Implements GrayLib::cX509Common.
|
overridevirtual |
Reimplemented from GrayLib::cX509Common.
GrayLib::cX509Crt::UNITTEST_FRIEND | ( | cX509Crt | ) |
X509_Verify_t GrayLib::cX509Crt::VerifyCrl | ( | const cX509Crt * | pCrtCA, |
const cX509Crl * | pCrl | ||
) | const |
Check that the given certificate is valid according to the CRL.
HRESULT GrayLib::cX509Crt::VerifyCrt | ( | const cX509Crt * | pCrtCA, |
const cX509Crl * | pCrl, | ||
const char * | cn, | ||
OUT X509_Verify_t & | rFlags, | ||
IX509VerifyCert * | pVerifyCert | ||
) | const |
Verify the certificate signature validity. The pVerifyCert callback is a user-supplied callback that can clear / modify / add flags for a certificate. If set, the verification callback is called for each certificate in the chain (from the trust-ca down to the presented crt). The parameters for the callback are: (cX509Crt* crt, int certificate_depth, X509_Verify_t* flags). With the flags representing current flags for that specific certificate and the certificate_depth from the bottom (Peer cert depth = 0).
All flags left after returning from the callback are also returned to the application. The function should return 0 for anything but a fatal error.
X509_Verify_t GrayLib::cX509Crt::VerifyKeyUsage | ( | X509_KeyUsage_TYPE | usage, |
bool | bEndpointIsServer | ||
) | const |
Check usage of a certificate wrt extensions:
HRESULT GrayLib::cX509Crt::WriteToDER | ( | BYTE * | pBuffer, |
size_t | size, | ||
const cASNSets & | extensions2, | ||
const cKeyWrap & | rIssuerKey, | ||
IRandomNoise * | pRandom | ||
) |
built up certificate to a X509 DER structure
HRESULT GrayLib::cX509Crt::WriteToPEM | ( | char * | pOut, |
StrLen_t | size, | ||
const cASNSets & | extensions2, | ||
const cKeyWrap & | rIssuerKey, | ||
IRandomNoise * | pRandom | ||
) |
built up certificate to a X509 PEM string
|
static |
"CERTIFICATE"
cX509CrtExt GrayLib::cX509Crt::m_Ext |
optional extensions. AKA ExtensionList.
cASNSets GrayLib::cX509Crt::m_issuer |
The parsed issuer (named information object). e.g. "CN=SDF ???".
cASNBuf GrayLib::cX509Crt::m_issuer_id |
Optional X.509 v2/v3 issuer unique identifier. UNUSED. X509_EXT_AUTHORITY_KEY_IDENTIFIER/OID_AUTHORITY_KEY_IDENTIFIER ?
cASNBufAlloc GrayLib::cX509Crt::m_SerialNumber |
Unique binary id for certificate issued by a specific CA. CertificateSerialNumber (RFC5280 size max = 32) cBigUnsigned ASN_INTEGER.
cASNSets GrayLib::cX509Crt::m_subject |
The parsed m_subject_raw (named information object).
cASNBuf GrayLib::cX509Crt::m_subject_id |
Optional X.509 v2/v3 subject unique identifier. UNUSED. X509_EXT_SUBJECT_KEY_IDENTIFIER/OID_SUBJECT_KEY_IDENTIFIER ?
cASNBuf GrayLib::cX509Crt::m_subject_raw |
for use in SSL_CERTIFICATE_REQUEST
cKeyWrap GrayLib::cX509Crt::m_SubjectPublicKey |
Container for the public key context. "SubjectPublicKeyInfo".
cTimeUnits GrayLib::cX509Crt::m_tValidFrom |
Start time of certificate validity.
cTimeUnits GrayLib::cX509Crt::m_tValidTo |
End time of certificate validity.