licensing: HWID diagnosability, matcher widening, delete-condition fix
- hwid.cpp: BitStream3 buffer 125 -> 160 bits (writes totalled 147 bits and overflowed the old allocation; encoded HWID bytes unchanged). Log component availability (uuid/cpu/mac/hdd) once per distinct HWID, and warn when WMI yields no components at all. - Matcher widened only, generation untouched: exact-string match short-circuits, UUID match accepts any WMI list entry (generator hashes the last valid one), fuzzy-match point breakdown is logged so field status-12 rejections are diagnosable. - ANSLicense.cpp: fix inverted delete condition (!p != NULL) at 6 sites; detect the shared "empty fingerprint" HWID of WMI-broken PCs and warn with repair steps; mask activation keys in error strings. - licensingclient.h: explain SetKey/validation/NTP failures on stderr. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -98,6 +98,16 @@ namespace {
|
||||
return s.substr(0, 4) + std::string(s.size() - 8, '*') + s.substr(s.size() - 4);
|
||||
}
|
||||
|
||||
// The HWID emitted when WMI returns no hardware components at all (every
|
||||
// hash field is the "absent" marker). Every PC with broken WMI produces
|
||||
// this exact string, so it identifies "WMI broken" in customer logs.
|
||||
constexpr const char* kEmptyFingerprintHWID = "ESWJJ-LEEFC-CCTBB-JSSWJ-JLEEF";
|
||||
|
||||
constexpr const char* kEmptyFingerprintWarning =
|
||||
"Hardware fingerprint is EMPTY - WMI returned no hardware components on this PC. "
|
||||
"Licensing proceeds but the license is weakly bound to this machine. "
|
||||
"Repair WMI: run 'winmgmt /verifyrepository' (then 'winmgmt /salvagerepository' if inconsistent).";
|
||||
|
||||
// SDK identifier passed to ANSLSHelper for licensing-service auth. Despite
|
||||
// the variable name "privateKey" used at call sites, this is an 11-byte
|
||||
// SDK token that identifies the ANSCENTER product to the licensing
|
||||
@@ -2166,7 +2176,7 @@ namespace ANSCENTER
|
||||
}
|
||||
void ANSLSHelper::LoadLicense(std::string licenseKey) {
|
||||
|
||||
if (!this->_license != NULL) delete this->_license;
|
||||
if (this->_license != NULL) delete this->_license;
|
||||
this->_license = new License();
|
||||
std::string licenseFileName = Dash2Underscore(licenseKey)+".json";
|
||||
std::string licenseFolder = GetLicenseDir();
|
||||
@@ -2812,6 +2822,9 @@ namespace ANSCENTER
|
||||
std::wstring _registrationName = String2WString(registrationName);
|
||||
std::wstring hardwareId = KeyHelper::GetCurrentHardwareId();
|
||||
std::string _hardwareId = WString2String(hardwareId);
|
||||
if (_hardwareId == kEmptyFingerprintHWID) {
|
||||
this->_logger.LogWarn("ANSLSHelper::ValidateLicenseKey", kEmptyFingerprintWarning, __FILE__, __LINE__);
|
||||
}
|
||||
bool _overrideLicenseFile = false;
|
||||
if (activationKey.empty()) {
|
||||
if (this->_license != NULL) {// get it from there
|
||||
@@ -2888,14 +2901,13 @@ namespace ANSCENTER
|
||||
|
||||
case STATUS_INVALID_HARDWARE_ID:
|
||||
_licenseKeyStatus = INVALID_HARDWARE_ID;
|
||||
activationStatusStr = "Hardware id does not match this computer. current HWID is " + _hardwareId +
|
||||
"; client HWID is " + WString2String(licensingClient.GetHardwareId()) +
|
||||
"; Current activation key is " + WString2String(_activationKey) +
|
||||
"; client Activation key is " + WString2String(licensingClient.GetActivationKey()) +
|
||||
"; URL is " + WString2String(this->_licenseServiceURL.c_str())+
|
||||
activationStatusStr = "Local hardware fingerprint check rejected this computer (hardware changed, or WMI returned no components). Current HWID is " + _hardwareId +
|
||||
"; stored activation key is " + mask_secret(WString2String(_activationKey)) +
|
||||
"; server activation key is " + mask_secret(WString2String(licensingClient.GetActivationKey())) +
|
||||
"; URL is " + WString2String(this->_licenseServiceURL.c_str())+
|
||||
"; ProductId is " + WString2String(wProductId) +
|
||||
"; RegistrationName is " + WString2String(_registrationName) +
|
||||
"; Status is" + std::to_string(activationStatus);
|
||||
"; Status is " + std::to_string(activationStatus);
|
||||
break;
|
||||
|
||||
case STATUS_LICENSE_EXPIRED:
|
||||
@@ -2969,7 +2981,7 @@ namespace ANSCENTER
|
||||
|
||||
if (_overrideLicenseFile) {
|
||||
this->_logger.LogDebug("ANSLSHelper::ValidateLicenseKey", "Override license key.", __FILE__, __LINE__);
|
||||
if (!this->_license != NULL) delete this->_license;
|
||||
if (this->_license != NULL) delete this->_license;
|
||||
this->_license = new License();
|
||||
this->_license->SetLicenseKey(_licenseKey.c_str());
|
||||
this->_license->SetLicenseKeyValidationData(validationData, validationDataLen);
|
||||
@@ -2996,7 +3008,7 @@ namespace ANSCENTER
|
||||
if (_overrideLicenseFile) {
|
||||
// Save license
|
||||
this->_logger.LogDebug("ANSLSHelper::ValidateLicenseKey", "Override license key.", __FILE__, __LINE__);
|
||||
if (!this->_license != NULL) delete this->_license;
|
||||
if (this->_license != NULL) delete this->_license;
|
||||
this->_license = new License();
|
||||
this->_license->SetLicenseKey(_licenseKey.c_str());
|
||||
this->_license->SetLicenseKeyValidationData(validationData, validationDataLen);
|
||||
@@ -3026,6 +3038,9 @@ namespace ANSCENTER
|
||||
std::wstring _registrationName = String2WString(registrationName);
|
||||
std::string _hardwareId = customHWID;
|
||||
std::wstring hardwareId = String2WString(customHWID);
|
||||
if (_hardwareId == kEmptyFingerprintHWID) {
|
||||
this->_logger.LogWarn("ANSLSHelper::ValidateLicenseWithCustomHWID", kEmptyFingerprintWarning, __FILE__, __LINE__);
|
||||
}
|
||||
bool _overrideLicenseFile = false;
|
||||
if (activationKey.empty()) {
|
||||
if (this->_license != NULL) {// get it from there
|
||||
@@ -3102,14 +3117,13 @@ namespace ANSCENTER
|
||||
|
||||
case STATUS_INVALID_HARDWARE_ID:
|
||||
_licenseKeyStatus = INVALID_HARDWARE_ID;
|
||||
activationStatusStr = "Hardware id does not match this computer. current HWID is " + _hardwareId +
|
||||
"; client HWID is " + WString2String(licensingClient.GetHardwareId()) +
|
||||
"; Current activation key is " + WString2String(_activationKey) +
|
||||
"; client Activation key is " + WString2String(licensingClient.GetActivationKey()) +
|
||||
activationStatusStr = "Local hardware fingerprint check rejected this computer (hardware changed, or WMI returned no components). Current HWID is " + _hardwareId +
|
||||
"; stored activation key is " + mask_secret(WString2String(_activationKey)) +
|
||||
"; server activation key is " + mask_secret(WString2String(licensingClient.GetActivationKey())) +
|
||||
"; URL is " + WString2String(this->_licenseServiceURL.c_str()) +
|
||||
"; ProductId is " + WString2String(wProductId) +
|
||||
"; RegistrationName is " + WString2String(_registrationName) +
|
||||
"; Status is" + std::to_string(activationStatus);
|
||||
"; Status is " + std::to_string(activationStatus);
|
||||
break;
|
||||
|
||||
case STATUS_LICENSE_EXPIRED:
|
||||
@@ -3183,7 +3197,7 @@ namespace ANSCENTER
|
||||
|
||||
if (_overrideLicenseFile) {
|
||||
this->_logger.LogDebug("ANSLSHelper::ValidateLicenseKey", "Override license key.", __FILE__, __LINE__);
|
||||
if (!this->_license != NULL) delete this->_license;
|
||||
if (this->_license != NULL) delete this->_license;
|
||||
this->_license = new License();
|
||||
this->_license->SetLicenseKey(_licenseKey.c_str());
|
||||
this->_license->SetLicenseKeyValidationData(validationData, validationDataLen);
|
||||
@@ -3210,7 +3224,7 @@ namespace ANSCENTER
|
||||
if (_overrideLicenseFile) {
|
||||
// Save license
|
||||
this->_logger.LogDebug("ANSLSHelper::ValidateLicenseKey", "Override license key.", __FILE__, __LINE__);
|
||||
if (!this->_license != NULL) delete this->_license;
|
||||
if (this->_license != NULL) delete this->_license;
|
||||
this->_license = new License();
|
||||
this->_license->SetLicenseKey(_licenseKey.c_str());
|
||||
this->_license->SetLicenseKeyValidationData(validationData, validationDataLen);
|
||||
@@ -3496,7 +3510,7 @@ namespace ANSCENTER
|
||||
return 0; // invalid
|
||||
}
|
||||
else {
|
||||
if (!this->_license != NULL) delete this->_license;
|
||||
if (this->_license != NULL) delete this->_license;
|
||||
this->_license = new License();
|
||||
this->_license->SetLicenseKey(_licenseKey.c_str());
|
||||
this->_license->SetLicenseKeyValidationData(validationData, validationDataLen);
|
||||
|
||||
Reference in New Issue
Block a user