- Added support for machine ID binding in license certificates, ensuring that if a machine ID is specified, it must match the current runtime machine ID for the license to be valid. - Introduced new tests to verify behavior for empty, matching, and mismatching machine IDs in certificates, enhancing the robustness of license validation. - Updated LicenseInfo struct to include MachineID field, reflecting the new binding requirement.
23 lines
354 B
Go
23 lines
354 B
Go
//go:build linux
|
|
|
|
package commercial
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func platformMachineID() string {
|
|
data, err := os.ReadFile("/etc/machine-id")
|
|
if err != nil {
|
|
data, err = os.ReadFile("/var/lib/dbus/machine-id")
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
}
|
|
id := strings.TrimSpace(strings.ToLower(string(data)))
|
|
if id == "" {
|
|
return ""
|
|
}
|
|
return id
|
|
}
|