从 x509 证书中获取 SCT 列表
Fetch SCT list from x509 certificate
如何从 PCCERT_CONTEXT 获取此 SCT 列表?有没有直接赢的API?
使用以下代码片段,我可以从 X509 证书中以字符串形式获取 SCT 列表
std::wstring GetSCTString(PCCERT_CONTEXT certInfo)
{
PCERT_EXTENSION ext;
ext = CertFindExtension(szOID_CT_CERT_SCTLIST, certInfo->pCertInfo->cExtension, certInfo->pCertInfo->rgExtension);
if (NULL != ext)
{
DWORD strSz(0);
if (CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, szOID_CT_CERT_SCTLIST, ext->Value.pbData, ext->Value.cbData, NULL, &strSz))
{
std::wstring Buff;
Buff.resize((strSz / sizeof(wchar_t)) + 1);
if (CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, szOID_CT_CERT_SCTLIST, ext->Value.pbData, ext->Value.cbData, (void*)Buff.data(), &strSz))
{
return Buff;
}
}
}
return std::wstring();
}
如何从 PCCERT_CONTEXT 获取此 SCT 列表?有没有直接赢的API?
使用以下代码片段,我可以从 X509 证书中以字符串形式获取 SCT 列表
std::wstring GetSCTString(PCCERT_CONTEXT certInfo)
{
PCERT_EXTENSION ext;
ext = CertFindExtension(szOID_CT_CERT_SCTLIST, certInfo->pCertInfo->cExtension, certInfo->pCertInfo->rgExtension);
if (NULL != ext)
{
DWORD strSz(0);
if (CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, szOID_CT_CERT_SCTLIST, ext->Value.pbData, ext->Value.cbData, NULL, &strSz))
{
std::wstring Buff;
Buff.resize((strSz / sizeof(wchar_t)) + 1);
if (CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, szOID_CT_CERT_SCTLIST, ext->Value.pbData, ext->Value.cbData, (void*)Buff.data(), &strSz))
{
return Buff;
}
}
}
return std::wstring();
}