bool RTCCertificate::WriteStructuredClone(JSStructuredCloneWriter* aWriter) const { nsNSSShutDownPreventionLock locker; if (isAlreadyShutDown() || !mPrivateKey || !mCertificate) { return false; } return JS_WriteUint32Pair(aWriter, RTCCERTIFICATE_SC_VERSION, mAuthType) && JS_WriteUint32Pair(aWriter, (mExpires >> 32) & 0xffffffff, mExpires & 0xffffffff) && WritePrivateKey(aWriter, locker) && WriteCertificate(aWriter, locker); }
bool CCertFileData::InstallCert() { for (size_t i = 0; i < m_pRequire->GetFileData()->GetFileList().size(); i++) { std::wstring strFileName = m_pRequire->GetFileData()->GetFileList()[i]; strFileName = CResourceManager::_()->GetFilePath(m_pWebsiteData->GetWebsiteType(), m_pWebsiteData->GetID(), strFileName.c_str()); HANDLE hFile = ::CreateFile(strFileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { DWORD dwFileSize = ::GetFileSize(hFile, NULL); char *pData = new char[dwFileSize + 1]; ::ReadFile(hFile, pData, dwFileSize, &dwFileSize, NULL); ::CloseHandle(hFile); pData[dwFileSize] = 0; std::string strFull = pData; std::wstring szData = AToW(strFull); WriteCertificate(szData); delete pData; /*for (size_t i = 0; i < strFull.length();) { size_t p = strFull.find_first_of("\r\n", i); std::string strLine; if (p != std::string::npos) { strLine = strFull.substr(i, p - i); while (strFull[p] == '\r' || strFull[p] == '\n') p++; i = p; } else { strLine = strFull.substr(i); i = strFull.length(); } if (strLine.substr(0, 5) == "-----") continue; strBase64 += strLine; } delete pData; int iBinaryLen = strBase64.length() * 4 / 3 + 10; BYTE *pBinary = new BYTE[iBinaryLen]; base64_decode((BYTE*)strBase64.c_str(), strBase64.length(), pBinary, &iBinaryLen); PCCERT_CONTEXT cc = ::CertCreateCertificateContext(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, pBinary, iBinaryLen); if (cc == NULL) { delete pBinary; return false; } BYTE hash[128]; DWORD dwLen = 128; ::CryptHashCertificate(0, 0, 0, cc->pbCertEncoded, cc->cbCertEncoded, hash, &dwLen); ::CertFreeCertificateContext(cc);*/ // 这里应当增加安装证书的功能,但应当将证书放入系统中? // 读入数据直接写到注册表里 // char szFingerPrintChar // AtlHexEncode //delete pBinary; } } return true; }