Configuration Options

The LicenseManager in the SDK provides several configuration options that allow you to tailor its behavior to your specific use cases, including air-gapped environments, logging control, offline support, and more.

Custom Logger (Resty)

The License Manager uses a Resty client to communicate with LicenseSpring’s API. By default, Resty logs to standard output. You can override this behavior by passing a custom logger using WithRestyLogger.

WithRestyLogger(restyLogger resty.Logger)
type CustomLogger struct{}

func (fl *CustomLogger) Debugf(format string, v ...interface{}) {}
func (fl *CustomLogger) Errorf(format string, v ...interface{}) {}
func (fl *CustomLogger) Warnf(format string, v ...interface{})  {}

lm_config := license_manager.LicenseManagerBasicConfiguration{
				OAuth:             false,
				ApiKey:            "your-api-key",
				SharedKey:         "your-shared-key",
				ProductCode:       "your-product-code",
				AuthData:          auth.FromKey("LICENSE-KEY"),
			}

lm, _ := license_manager.NewLicenseManager(
    lm_config,
    license_manager.WithRestyLogger(CustomLogger),
)

cfg.Manager = lm

lh, _ := license_handler.NewLicenseHandler(cfg)

WithAirGapPublicKey

circle-info

This option is required for air-gapped licenses. The AirGap public key can be found on your LicenseSpring dashboard and is separate from your API and Shared keys.

WithGracePeriod

By default, the SDK allows the license to be offline for 48 hours before invalidating it. This option lets you customize the duration of this grace period.

WithSyncPeriod

Sets how frequently (in seconds) the SDK should try to synchronize the license with the server.

WithRestyVerbose

When set to true, the SDK outputs detailed logs for LicenseClient operations.

WithVerifySignature

When enabled, this option enforces signature verification on all responses from LicenseSpring.

WithEnableGuardFile

This enables the use of guard files to protect against reuse of offline activation requests and ensure that hardware IDs match.

WithHardwareId

Overrides the hardware ID used to identify the device.

WithAppName

Overrides the App Name.

WithAppVersion

Overrides the App Version.

WithServerPublicKey

Overrides the server public key used to verify the signature in API responses. Setting up this value is mandatory if you are using a server other than LicenseSpring's servers.

WithHardwareIdAlgo

Overrides the hardware ID used to identify the device. You can use this configuration option if you want to enable the built-in hardware ID module, which supports multiple hardware ID algorithms. You’ll need to select one of the supported algorithms from the list below:

  • HWIDAlgorithmWindowsFingerprint

  • HWIDAlgorithmComputerSystemProduct

  • HWIDAlgorithmCryptography

  • HWIDAlgorithmLinuxMachineID

  • HWIDAlgorithmCloudPlatform

Each algorithm generates the hardware ID differently depending on the operating system and environment. Choose the one that best fits your use case.

WithMachineId

Overrides the hardware ID and sets it to match the machine ID used in SDK v1. Use this option if you want to maintain compatibility with the hardware ID format from v1.

Hardware Key Support

Starting with Go SDK v2.1.0, the SDK supports hardware keys and licenses that require a provisioned hardware key to be attached to the machine for all API calls. To use these licenses, you must initialize the SDK with additional configuration options so it can detect the hardware key, derive the correct hardware ID, and perform signing.

WithHWKeySerialAsHWID

Required when using a hardware key.

This option forces the SDK to use the hardware key’s serial number as the hardware ID. The license API validates the hardware ID against the provisioned hardware key; if you do not enable this option, the hardware ID will not match and API calls will fail.

WithCryptoSigner

Advanced / uncommon. Use this only if you are using a hardware key license but want to provide your own signer implementation. In most cases you do not need this option.

WithDisableHWKEYVerify

Skip hardware key verification entirely.

If set to true, the SDK will not check for the presence of the hardware key and will skip hardware-key verification logic.

WithHardwareKeyPIN

Set a custom PIN for the hardware key.

If you have changed the hardware key PIN, provide it here. Otherwise, the SDK uses the default PIN: "123456".

Last updated

Was this helpful?