- 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.
27 lines
557 B
Go
27 lines
557 B
Go
//go:build darwin
|
|
|
|
package commercial
|
|
|
|
import (
|
|
"os/exec"
|
|
"strings"
|
|
)
|
|
|
|
func platformMachineID() string {
|
|
out, err := exec.Command("ioreg", "-rd1", "-c", "IOPlatformExpertDevice").Output()
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
for _, line := range strings.Split(string(out), "\n") {
|
|
if strings.Contains(line, "IOPlatformUUID") {
|
|
parts := strings.SplitN(line, "=", 2)
|
|
if len(parts) == 2 {
|
|
uuid := strings.Trim(strings.TrimSpace(parts[1]), "\"")
|
|
if uuid != "" {
|
|
return strings.TrimSpace(strings.ToLower(uuid))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return ""
|
|
}
|