> For the complete documentation index, see [llms.txt](https://docs.licensespring.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.licensespring.com/sdks/go-sdk/v2/handler/configuration-options.md).

# 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.

```go
WithRestyLogger(restyLogger resty.Logger)
```

```go
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

```go
WithAirGapPublicKey(airgappublickey string)
```

{% hint style="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.
{% endhint %}

## WithGracePeriod

```go
WithGracePeriod(gracePeriod int)
```

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

```go
WithSyncPeriod(syncPeriod int)
```

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

## WithRestyVerbose

```go
WithRestyVerbose(verbose bool)
```

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

## WithVerifySignature

```go
WithVerifySignature(verifySig bool)
```

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

## WithEnableGuardFile

```go
WithEnableGuardFile(enableGuardFile bool)
```

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

## WithHardwareId

```go
WithHardwareId(hardwareId string)
```

Overrides the hardware ID used to identify the device.

## WithAppName

```go
WithAppName(appName string)
```

Overrides the App Name.

## WithAppVersion

```go
WithAppVersion(appVersion string)
```

Overrides the App Version.

## WithServerPublicKey

```go
WithServerPublicKey(publicKey string)
```

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

```go
WithHardwareIdAlgo(hardwareId string)
```

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.

```go
const (
	Default HardwareIdAlgorithm = iota
	WindowsHardwareFingerprintId
	WindowsComputerSystemProductId
	WindowsCryptographyId
	LinuxMachineId
	CloudPlatformsId
)
```

## WithMachineId

```go
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

```go
WithHWKeySerialAsHWID()
```

**Required when using a hardware key.**&#x20;

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

```go
WithCryptoSigner(signer crypto.Signer)
```

**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.

## WithEnableHWKEYVerify

```go
WithEnableHWKEYVerify()
```

**Skip hardware key verification entirely.**

Only with this configuration, the SDK will check for the presence of the hardware key and will skip hardware-key verification logic. otherwise.

## WithHardwareKeyPIN

```go
WithHardwareKeyPIN(pin string)
```

**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"`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.licensespring.com/sdks/go-sdk/v2/handler/configuration-options.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
