From fe945f88cb2f9e0c0bc73cc879e6af743d2be320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E6=9D=B0?= Date: Tue, 8 Jul 2025 20:10:07 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文杰 --- frameworks/js/napi/fetch/fetch_exec/include/fetch_exec.h | 2 +- frameworks/js/napi/fetch/fetch_exec/src/fetch_exec.cpp | 2 +- .../js/napi/net_ssl/async_context/src/cert_context.cpp | 3 ++- frameworks/native/net_ssl/include/net_ssl_verify_cert.h | 6 ++++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/frameworks/js/napi/fetch/fetch_exec/include/fetch_exec.h b/frameworks/js/napi/fetch/fetch_exec/include/fetch_exec.h index d479afedd..d2b6125b9 100644 --- a/frameworks/js/napi/fetch/fetch_exec/include/fetch_exec.h +++ b/frameworks/js/napi/fetch/fetch_exec/include/fetch_exec.h @@ -65,7 +65,7 @@ private: private: static std::mutex mutex_; - static bool initialized_; + static std::atomic initialized_; }; } // namespace OHOS::NetStack::Fetch diff --git a/frameworks/js/napi/fetch/fetch_exec/src/fetch_exec.cpp b/frameworks/js/napi/fetch/fetch_exec/src/fetch_exec.cpp index 839c68038..b40c8459e 100644 --- a/frameworks/js/napi/fetch/fetch_exec/src/fetch_exec.cpp +++ b/frameworks/js/napi/fetch/fetch_exec/src/fetch_exec.cpp @@ -63,7 +63,7 @@ static constexpr const int FAIL_CALLBACK_PARAM = 2; namespace OHOS::NetStack::Fetch { std::mutex FetchExec::mutex_; -bool FetchExec::initialized_ = false; +std::atomic FetchExec::initialized_ = false; bool FetchExec::ExecFetch(FetchContext *context) { diff --git a/frameworks/js/napi/net_ssl/async_context/src/cert_context.cpp b/frameworks/js/napi/net_ssl/async_context/src/cert_context.cpp index ffb1d5598..c6f907789 100644 --- a/frameworks/js/napi/net_ssl/async_context/src/cert_context.cpp +++ b/frameworks/js/napi/net_ssl/async_context/src/cert_context.cpp @@ -52,7 +52,8 @@ static const std::map SSL_ERR_MAP = { {SslErrorCode::SSL_X509_V_ERR_INVALID_CA, "Invalid certificate authority (CA)."}, {SslErrorCode::SSL_X509_V_ERR_CERT_UNTRUSTED, "Certificate is untrusted."}, {SslErrorCode::SSL_X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT, "self-signed certificate."}, - {SslErrorCode::SSL_X509_V_ERR_INVALID_CALL, "invalid certificate verification context."} + {SslErrorCode::SSL_X509_V_ERR_INVALID_CALL, "invalid certificate verification context."}, + {SslErrorCode::SSL_X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY, "unable to get local issuer certificate."} }; CertContext::CertContext(napi_env env, const std::shared_ptr &manager) diff --git a/frameworks/native/net_ssl/include/net_ssl_verify_cert.h b/frameworks/native/net_ssl/include/net_ssl_verify_cert.h index 843aa81a7..944107aa6 100644 --- a/frameworks/native/net_ssl/include/net_ssl_verify_cert.h +++ b/frameworks/native/net_ssl/include/net_ssl_verify_cert.h @@ -62,7 +62,8 @@ enum SslErrorCode { // The following error codes are added since API12 SSL_X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = SSL_ERROR_CODE_BASE + X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT, SSL_X509_V_ERR_INVALID_CALL = SSL_ERROR_CODE_BASE + X509_V_ERR_INVALID_CALL, - SSL_X509_V_ERR_OUT_OF_MEMORY = SSL_ERROR_CODE_BASE + 999 + SSL_X509_V_ERR_OUT_OF_MEMORY = SSL_ERROR_CODE_BASE + 999, + SSL_X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = SSL_ERROR_CODE_BASE + X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY }; static const std::multiset SslErrorCodeSetBase{SSL_NONE_ERR, @@ -103,7 +104,8 @@ static const std::multiset SslErrorCodeSetSinceAPI12{SSL_NONE_ERR, // New error code since API12. SSL_X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT, SSL_X509_V_ERR_INVALID_CALL, - SSL_X509_V_ERR_OUT_OF_MEMORY}; + SSL_X509_V_ERR_OUT_OF_MEMORY, + SSL_X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY}; std::string GetUserInstalledCaPath(); -- Gitee From 44ce215d322e7e4e19af6a6eac4aa70ba62537c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E6=9D=B0?= Date: Tue, 8 Jul 2025 12:54:04 +0000 Subject: [PATCH 2/4] update frameworks/native/net_ssl/include/net_ssl_verify_cert.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文杰 --- frameworks/native/net_ssl/include/net_ssl_verify_cert.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frameworks/native/net_ssl/include/net_ssl_verify_cert.h b/frameworks/native/net_ssl/include/net_ssl_verify_cert.h index 944107aa6..016dc6426 100644 --- a/frameworks/native/net_ssl/include/net_ssl_verify_cert.h +++ b/frameworks/native/net_ssl/include/net_ssl_verify_cert.h @@ -63,7 +63,8 @@ enum SslErrorCode { SSL_X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = SSL_ERROR_CODE_BASE + X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT, SSL_X509_V_ERR_INVALID_CALL = SSL_ERROR_CODE_BASE + X509_V_ERR_INVALID_CALL, SSL_X509_V_ERR_OUT_OF_MEMORY = SSL_ERROR_CODE_BASE + 999, - SSL_X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = SSL_ERROR_CODE_BASE + X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY + SSL_X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = SSL_ERROR_CODE_BASE + + X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY }; static const std::multiset SslErrorCodeSetBase{SSL_NONE_ERR, -- Gitee From 9a39a4ea9359d9f089e90101061eea774d56145f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E6=9D=B0?= Date: Wed, 9 Jul 2025 02:24:20 +0000 Subject: [PATCH 3/4] update frameworks/js/napi/net_ssl/async_context/src/cert_context.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文杰 --- frameworks/js/napi/net_ssl/async_context/src/cert_context.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/js/napi/net_ssl/async_context/src/cert_context.cpp b/frameworks/js/napi/net_ssl/async_context/src/cert_context.cpp index c6f907789..604f5aba4 100644 --- a/frameworks/js/napi/net_ssl/async_context/src/cert_context.cpp +++ b/frameworks/js/napi/net_ssl/async_context/src/cert_context.cpp @@ -48,12 +48,12 @@ static const std::map SSL_ERR_MAP = { {SslErrorCode::SSL_X509_V_ERR_CERT_HAS_EXPIRED, "Certificate has expired."}, {SslErrorCode::SSL_X509_V_ERR_CRL_NOT_YET_VALID, "CRL is not yet valid."}, {SslErrorCode::SSL_X509_V_ERR_CRL_HAS_EXPIRED, "CRL has expired."}, + {SslErrorCode::SSL_X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY, "unable to get local issuer certificate."}, {SslErrorCode::SSL_X509_V_ERR_CERT_REVOKED, "Certificate has been revoked."}, {SslErrorCode::SSL_X509_V_ERR_INVALID_CA, "Invalid certificate authority (CA)."}, {SslErrorCode::SSL_X509_V_ERR_CERT_UNTRUSTED, "Certificate is untrusted."}, {SslErrorCode::SSL_X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT, "self-signed certificate."}, - {SslErrorCode::SSL_X509_V_ERR_INVALID_CALL, "invalid certificate verification context."}, - {SslErrorCode::SSL_X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY, "unable to get local issuer certificate."} + {SslErrorCode::SSL_X509_V_ERR_INVALID_CALL, "invalid certificate verification context."} }; CertContext::CertContext(napi_env env, const std::shared_ptr &manager) -- Gitee From 41c6c112fff134a7079c4ec249d11e81c35f14b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E6=9D=B0?= Date: Wed, 9 Jul 2025 02:26:11 +0000 Subject: [PATCH 4/4] update frameworks/native/net_ssl/include/net_ssl_verify_cert.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文杰 --- .../native/net_ssl/include/net_ssl_verify_cert.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frameworks/native/net_ssl/include/net_ssl_verify_cert.h b/frameworks/native/net_ssl/include/net_ssl_verify_cert.h index 016dc6426..98532cd7e 100644 --- a/frameworks/native/net_ssl/include/net_ssl_verify_cert.h +++ b/frameworks/native/net_ssl/include/net_ssl_verify_cert.h @@ -56,15 +56,15 @@ enum SslErrorCode { SSL_X509_V_ERR_CERT_HAS_EXPIRED = SSL_ERROR_CODE_BASE + X509_V_ERR_CERT_HAS_EXPIRED, SSL_X509_V_ERR_CRL_NOT_YET_VALID = SSL_ERROR_CODE_BASE + X509_V_ERR_CRL_NOT_YET_VALID, SSL_X509_V_ERR_CRL_HAS_EXPIRED = SSL_ERROR_CODE_BASE + X509_V_ERR_CRL_HAS_EXPIRED, + SSL_X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = + SSL_ERROR_CODE_BASE + X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY, SSL_X509_V_ERR_CERT_REVOKED = SSL_ERROR_CODE_BASE + X509_V_ERR_CERT_REVOKED, SSL_X509_V_ERR_INVALID_CA = SSL_ERROR_CODE_BASE + X509_V_ERR_INVALID_CA, SSL_X509_V_ERR_CERT_UNTRUSTED = SSL_ERROR_CODE_BASE + X509_V_ERR_CERT_UNTRUSTED, // The following error codes are added since API12 SSL_X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = SSL_ERROR_CODE_BASE + X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT, SSL_X509_V_ERR_INVALID_CALL = SSL_ERROR_CODE_BASE + X509_V_ERR_INVALID_CALL, - SSL_X509_V_ERR_OUT_OF_MEMORY = SSL_ERROR_CODE_BASE + 999, - SSL_X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = SSL_ERROR_CODE_BASE - + X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY + SSL_X509_V_ERR_OUT_OF_MEMORY = SSL_ERROR_CODE_BASE + 999 }; static const std::multiset SslErrorCodeSetBase{SSL_NONE_ERR, @@ -99,14 +99,14 @@ static const std::multiset SslErrorCodeSetSinceAPI12{SSL_NONE_ERR, SSL_X509_V_ERR_CERT_HAS_EXPIRED, SSL_X509_V_ERR_CRL_NOT_YET_VALID, SSL_X509_V_ERR_CRL_HAS_EXPIRED, + SSL_X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY, SSL_X509_V_ERR_CERT_REVOKED, SSL_X509_V_ERR_INVALID_CA, SSL_X509_V_ERR_CERT_UNTRUSTED, // New error code since API12. SSL_X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT, SSL_X509_V_ERR_INVALID_CALL, - SSL_X509_V_ERR_OUT_OF_MEMORY, - SSL_X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY}; + SSL_X509_V_ERR_OUT_OF_MEMORY}; std::string GetUserInstalledCaPath(); -- Gitee