mirror of
https://gitee.com/openharmony/security_certificate_framework
synced 2024-11-23 14:39:44 +00:00
commit
b035abceba
@ -262,11 +262,8 @@ static X509 *GetX509FromHcfX509Certificate(const HcfCertificate *cert)
|
||||
return realCert->x509;
|
||||
}
|
||||
|
||||
static CfResult CheckCertChainIsRevoked(const STACK_OF(X509_CRL) * crlStack, const STACK_OF(X509) * certChain)
|
||||
static CfResult CheckCertChainIsRevoked(const STACK_OF(X509_CRL) *crlStack, const STACK_OF(X509) *certChain)
|
||||
{
|
||||
X509 *cert = NULL;
|
||||
X509_CRL *crl = NULL;
|
||||
int32_t res = 0;
|
||||
int cerNum = sk_X509_num(certChain);
|
||||
if (cerNum == 0) {
|
||||
LOGE("sk X509 num : 0, failed !");
|
||||
@ -276,7 +273,7 @@ static CfResult CheckCertChainIsRevoked(const STACK_OF(X509_CRL) * crlStack, con
|
||||
|
||||
int crlNum = sk_X509_CRL_num(crlStack); // allow crlNum : 0, no crl
|
||||
for (int i = 0; i < crlNum; ++i) {
|
||||
crl = sk_X509_CRL_value(crlStack, i);
|
||||
X509_CRL *crl = sk_X509_CRL_value(crlStack, i);
|
||||
if (crl == NULL) {
|
||||
LOGE("sk X509 CRL value is null, failed !");
|
||||
CfPrintOpensslError();
|
||||
@ -284,16 +281,16 @@ static CfResult CheckCertChainIsRevoked(const STACK_OF(X509_CRL) * crlStack, con
|
||||
}
|
||||
|
||||
/* crl in certcrlcollection object is not null. */
|
||||
X509_REVOKED *rev = NULL;
|
||||
for (int j = 0; j < cerNum; ++j) {
|
||||
cert = sk_X509_value(certChain, j);
|
||||
X509 *cert = sk_X509_value(certChain, j);
|
||||
if (cert == NULL) {
|
||||
LOGE("sk X509 value is null, failed !");
|
||||
CfPrintOpensslError();
|
||||
return CF_ERR_CRYPTO_OPERATION;
|
||||
}
|
||||
|
||||
res = X509_CRL_get0_by_cert(crl, &rev, cert);
|
||||
X509_REVOKED *rev = NULL;
|
||||
int32_t res = X509_CRL_get0_by_cert(crl, &rev, cert);
|
||||
if (res != 0) {
|
||||
LOGE("cert is revoked.");
|
||||
return CF_ERR_CRYPTO_OPERATION;
|
||||
|
@ -207,7 +207,8 @@ static int32_t DeepCopyDataToOutblob(const char *data, uint32_t len, CfBlob *out
|
||||
return CF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t DeepCopyOidsToOut(const X509_EXTENSIONS *exts, uint32_t *idxArray, uint32_t arrayLen, CfBlobArray *out)
|
||||
static int32_t DeepCopyOidsToOut(const X509_EXTENSIONS *exts, const uint32_t *idxArray, uint32_t arrayLen,
|
||||
CfBlobArray *out)
|
||||
{
|
||||
uint32_t memSize = sizeof(CfBlob) * arrayLen;
|
||||
CfBlob *dataArray = (CfBlob *)CfMalloc(memSize);
|
||||
|
@ -121,11 +121,6 @@ static bool CreateCallbackAndPromise(
|
||||
static void CreateCertChainExecute(napi_env env, void *data)
|
||||
{
|
||||
CfCtx *context = static_cast<CfCtx *>(data);
|
||||
if (context == nullptr) {
|
||||
context->async->errCode = CF_INVALID_PARAMS;
|
||||
context->async->errMsg = "context is nullptr";
|
||||
return;
|
||||
}
|
||||
context->async->errCode = HcfCertChainCreate(context->encodingBlob, nullptr, &context->certChain);
|
||||
if (context->async->errCode != CF_SUCCESS) {
|
||||
context->async->errMsg = "create cert chain failed";
|
||||
@ -189,12 +184,6 @@ static void ValidateExecute(napi_env env, void *data)
|
||||
{
|
||||
LOGI("enter");
|
||||
CfCtx *context = static_cast<CfCtx *>(data);
|
||||
if (context == nullptr || context->certChain == nullptr) {
|
||||
context->async->errCode = CF_INVALID_PARAMS;
|
||||
context->async->errMsg = "context or cert chain is invalid";
|
||||
return;
|
||||
}
|
||||
|
||||
context->async->errCode = context->certChain->validate(context->certChain, &context->params, &context->result);
|
||||
if (context->async->errCode != CF_SUCCESS) {
|
||||
context->async->errMsg = "create cert chain failed";
|
||||
|
Loading…
Reference in New Issue
Block a user