Browse Source

Z991239-5492 #comment feat: 1.修改私钥空时候的话术 2. 修复错误页一直在探测中的问题

陈纪林80310970 1 year ago
parent
commit
831b54c6c2

+ 5 - 57
Module/mod_accessauth/mod_AccessAuth.cpp

@@ -614,12 +614,12 @@ int CAccessAuthEntity::GetPinPadCapability()
 }
 
 void CAccessAuthEntity::printPasswdError(const string& strErrMsg){
-	//string strErrMsg = "密钥集丢失,请重新初始化密钥!";
 	SetAuthErrMsg(strErrMsg.c_str());
 	GetFunction()->SetSysVar("AuthErrMsg", strErrMsg.c_str(), true);
 	m_FSM.doWarnMsg( ERROR_ACCESSAUTH_OPENCRYPTCONTEXT, strErrMsg.c_str(),true, strErrMsg);
-	DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA520C")("密钥集丢失(私钥为空)");
+	DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA520C")(strErrMsg.c_str());
 }
+
 int Char2Int(char * ch) {
 	int num = 0;
 	for (int i = 0;i < strlen(ch);i++) {
@@ -660,7 +660,7 @@ bool CAccessAuthEntity::SaveAuthKey(BYTE *pKey)
 #endif // RVC_OS_WIN
 		if (strlen(privateKey) <= 0)
 		{
-			printPasswdError("密钥集丢失(私钥为空,请重置秘钥进行初始化");
+			printPasswdError("私钥为空,请重置秘钥进行初始化");
 			return false;
 		}
 	}
@@ -928,59 +928,6 @@ struct PublicKeyBlob
 };
 #endif // RVC_OS_WIN
 
-// 生成SM2密钥对,并导出公钥
-bool CAccessAuthEntity::GetTerminalPublicKey(BYTE* pBuf, int& nBufLen)
-{
-	CSimpleStringA runInfoPath, iniPath;
-	auto rc = GetFunction()->GetPath("runinfo", runInfoPath);
-	if (rc != Error_Succeed) {
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetTerminalPublicKey")
-			("GetPath runinfo error=%d.", rc);
-		return false;
-	}
-
-	char publicKey[BUF_SIZE] = { 0 };
-#ifdef RVC_OS_WIN
-	iniPath = runInfoPath + "\\runcfg\\AccessAuthorization.ini";
-	GetPrivateProfileString("TerminalPD", "PublicKey", "", publicKey, BUF_SIZE, iniPath.GetData());
-#else
-	iniPath = runInfoPath + SPLIT_SLASH_STR "runcfg" SPLIT_SLASH_STR "AccessAuthorization.ini";
-	char* tmp = inifile_read_str(iniPath.GetData(), "TerminalPD", "PublicKey", "");
-	strcpy(publicKey, tmp);
-	delete tmp;
-#endif // RVC_OS_WIN
-	if (strlen(publicKey) <= 0) {
-#ifdef RVC_OS_WIN
-		iniPath = runInfoPath + "\\runcfg\\Initializer.ini";
-		GetPrivateProfileString("TerminalPD", "PublicKey", "", publicKey, BUF_SIZE, iniPath.GetData());
-#else
-		iniPath = runInfoPath + SPLIT_SLASH_STR "runcfg" SPLIT_SLASH_STR "Initializer.ini";
-		char* tmp2 = inifile_read_str(iniPath.GetData(), "TerminalPD", "PublicKey", "");
-		strcpy(publicKey, tmp2);
-		delete tmp2;
-#endif // RVC_OS_WIN
-
-		if (strlen(publicKey) <= 0)
-		{
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI("GetTerminalPublicKey")("读取公钥失败,公钥长度小于等于零!");
-			if (!ExistsFileA(iniPath))
-				printPasswdError("密钥集丢失(公钥为空),请重置秘钥进行初始化");
-			return false;
-		}
-	}
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetTerminalPublicKey")("publickey=%s,%d", publicKey, strlen(publicKey));
-
-#ifdef RVC_OS_WIN
-	char* pDecodedPublickey = MyBase64::Hex2Str(publicKey, nBufLen);
-#else
-	char* pDecodedPublickey = Hex2Str(publicKey, nBufLen);
-#endif // RVC_OS_WIN
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetTerminalPublicKey")("pDecodedPublickey len=%d", nBufLen);
-	memcpy(pBuf, pDecodedPublickey, nBufLen);
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetTerminalPublicKey")("pBuf[0]=%02X,nBufLen=%d", pBuf[0], nBufLen);
-	delete[] pDecodedPublickey;
-	return true;
-}
 // 生成RSA密钥对,并导出公钥
 bool CAccessAuthEntity::GetTerminalPublicKey(BYTE* pBuf, int& nBufLen, string& pubkey)
 {
@@ -1069,7 +1016,8 @@ bool CAccessAuthEntity::GetTerminalPublicKey(BYTE* pBuf, int& nBufLen, string& p
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetTerminalPublicKey")("encode pri key success.");
 
 	m_privateKey = pEncodedCryptPrivateKey;
-	/*rc = pConfig->WriteConfigValue("TerminalPD", "PrivateKey", pEncodedCryptPrivateKey);
+	/*//不在这里写入私钥,将逻辑修改到函数外部,等服务端返回成功后再写入私钥
+	rc = pConfig->WriteConfigValue("TerminalPD", "PrivateKey", pEncodedCryptPrivateKey);
 	if (rc != Error_Succeed) {
 		rc = pConfig->WriteConfigValue("TerminalPD", "PublicKey", "");
 		delete[] pEncodedCryptPrivateKey;

+ 0 - 1
Module/mod_accessauth/mod_AccessAuth.h

@@ -143,7 +143,6 @@ public:
 	ErrorCodeEnum EncryptDataWithSessionKey(const CBlob& raw, CBlob& enc);
 
 	bool GetTerminalFingerPrint(BYTE* pBuf, int& nBufLen);
-	bool GetTerminalPublicKey(BYTE* pBuf, int& nBufLen);
 	bool GetTerminalPublicKey(BYTE* pBuf, int& nBufLen, string& pubkey);
 
 	void SetAuthErrMsg(const char* pszErrMsg) { m_strAuthErrMsg = pszErrMsg; }

+ 10 - 9
addin/res/ManagerDesktop/js/entityCheck.js

@@ -1,6 +1,6 @@
-let retest =['N']
+let retest =['N','N']
 let Len = 2
-let resultY = ['Y']
+let resultY = ['Y','Y']
 
 let set_retest = function(val,event){
 	retest = val
@@ -10,7 +10,7 @@ let set_retest = function(val,event){
 }
 
 let test = function(){
-  if(retest.join('') !== resultY.join('')){
+  if(retest.join('') == resultY.join('')){
     $('#retestBtn').attr('disabled',false)
     $('#retestBtn').html('重新检测')
   }
@@ -52,7 +52,7 @@ function getBizLinks(){
   req.filter = 1;
   req.timeout = 60000;
 	let timeoutFn= setTimeout(function(){
-    retest[1] = 'Y'
+    retest[2] = 'Y'
     set_retest(retest,test)
 
     retest.push('N')
@@ -75,8 +75,7 @@ function getBizLinks(){
 
 	ResourceWatcherService.GetBizLinks(req, function(res) {
 		logEvent("GetBizLinks ret: "+JSON.stringify(res));
-    console.info("GetBizLinks ret1: "+JSON.stringify(res));
-    console.info("GetBizLinks ret2: "+res.bizLinks);
+    console.log("GetBizLinks ret: "+JSON.stringify(res));
 
 		if(res){
 			clearTimeout(timeoutFn);
@@ -182,9 +181,9 @@ function getBizLinkDetect(url,urlTitle,idx){
     let elem = document.querySelector('.bizLinkDetect'+idx+' .icon-type');
 		elem&&elem.classList.add('icon-err')
     $('.bizLinkDetect'+idx+' p').html('「'+dateTime+'」'+urlTitle+'检测失败')
-    retest[1+idx] = 'Y'
+    retest[2+idx] = 'Y'
     set_retest(retest,test)
-    testResult[1+idx] = 'N'
+    testResult[2+idx] = 'N'
     set_testResult(testResult,goBusiHome)
 	},60000)
 
@@ -192,7 +191,7 @@ function getBizLinkDetect(url,urlTitle,idx){
 		logEvent("BizLinkDetect ret: "+JSON.stringify(res));
 		if(res){
 			clearTimeout(timeoutFn);
-      retest[1+idx] = 'Y'
+      retest[2+idx] = 'Y'
       set_retest(retest,test)
 
       $('.bizLinkDetect'+idx).fadeIn();
@@ -224,6 +223,8 @@ function getBizLinkDetect(url,urlTitle,idx){
 }
 // 网卡连接-删除后,检测按钮异常,临时方案
 function getNetCardLink(){
+  retest[1] = 'Y'
+  set_retest(retest,test)
   testResult[1] = 'Y'
   set_testResult(testResult,goBusiHome)
 }