|
@@ -52,17 +52,17 @@ func ValidateLicense() error {
|
|
|
logger.Log(0, "proceeding with Netmaker license validation...")
|
|
|
if len(licenseKeyValue) == 0 || len(netmakerTenantID) == 0 {
|
|
|
err := fmt.Errorf("license-key: %s, tenant-id: %s", licenseKeyValue, netmakerTenantID)
|
|
|
- logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err))
|
|
|
+ logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err).Error())
|
|
|
}
|
|
|
|
|
|
apiPublicKey, err := getLicensePublicKey(licenseKeyValue)
|
|
|
if err != nil {
|
|
|
- logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err))
|
|
|
+ logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err).Error())
|
|
|
}
|
|
|
|
|
|
tempPubKey, tempPrivKey, err := FetchApiServerKeys()
|
|
|
if err != nil {
|
|
|
- logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err))
|
|
|
+ logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err).Error())
|
|
|
}
|
|
|
|
|
|
licenseSecret := LicenseSecret{
|
|
@@ -72,33 +72,33 @@ func ValidateLicense() error {
|
|
|
|
|
|
secretData, err := json.Marshal(&licenseSecret)
|
|
|
if err != nil {
|
|
|
- logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err))
|
|
|
+ logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err).Error())
|
|
|
}
|
|
|
|
|
|
encryptedData, err := ncutils.BoxEncrypt(secretData, apiPublicKey, tempPrivKey)
|
|
|
if err != nil {
|
|
|
- logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err))
|
|
|
+ logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err).Error())
|
|
|
}
|
|
|
|
|
|
validationResponse, err := validateLicenseKey(encryptedData, tempPubKey)
|
|
|
if err != nil || len(validationResponse) == 0 {
|
|
|
err := fmt.Errorf("err: %w, validation-response: %s", err, string(validationResponse))
|
|
|
- logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err))
|
|
|
+ logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err).Error())
|
|
|
}
|
|
|
|
|
|
var licenseResponse ValidatedLicense
|
|
|
if err = json.Unmarshal(validationResponse, &licenseResponse); err != nil {
|
|
|
- logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err))
|
|
|
+ logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err).Error())
|
|
|
}
|
|
|
|
|
|
respData, err := ncutils.BoxDecrypt(base64decode(licenseResponse.EncryptedLicense), apiPublicKey, tempPrivKey)
|
|
|
if err != nil {
|
|
|
- logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err))
|
|
|
+ logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err).Error())
|
|
|
}
|
|
|
|
|
|
license := LicenseKey{}
|
|
|
if err = json.Unmarshal(respData, &license); err != nil {
|
|
|
- logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err))
|
|
|
+ logger.FatalLog0(fmt.Errorf("%w: %w", errValidation, err).Error())
|
|
|
}
|
|
|
|
|
|
logger.Log(0, "License validation succeeded!")
|