> 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/samples/air-gap-license.md).

# Air Gap License

In highly secure environments where systems are completely disconnected from the internet (air-gapped), standard online or offline activation methods involving file exchange may not be suitable. To address this, the LicenseSpring SDK offers an **Air-Gap Activation** mechanism using code-based exchange.

This guide explains how to use the air-gap flow to activate licenses without transferring files.

## Overview of the Air-Gap Flow

{% stepper %}
{% step %}

### Retrieve an Initialization Code

Obtain an initialization code from the LicenseSpring Air-Gap Portal.
{% endstep %}

{% step %}

### Generate an Activation Code

Use the SDK and the initialization code to generate an activation code.
{% endstep %}

{% step %}

### Submit the Activation Code

Submit the activation code to the Air-Gap Portal to receive a confirmation code.
{% endstep %}

{% step %}

### Activate the License

Use the confirmation code and the policy data on the air-gapped machine to activate the license.
{% endstep %}
{% endstepper %}

Each step is handled by SDK functions that require certain inputs provided via the portal or platform settings.

## Step 1: Generate Activation Code

Use the initialization code retrieved from the air-gap portal to generate an activation code:

{% code title="generate\_activation.go" %}

```go
// Generate an activation code using the initialization code and license key.
// This code must be submitted to the Air-Gap Portal to receive a confirmation code.
activationCode, err := lh.GetAirGapActivationCode(initializationCode, licenseKey)
if err != nil {
	fmt.Printf("failed to generate air-gap activation code: %w", err)
	return err
}
fmt.Printf("Activation Code: %s\n", activationCode)
```

{% endcode %}

* `initializationCode`: Provided by the Air-Gap Portal.
* `licenseKey`: Retrieved from the authentication data provided in configuration.

Print and store the activation code. You will paste this back into the Air-Gap Portal to obtain a confirmation code.

## Step 2: Activate License Using Confirmation Code

After receiving the confirmation code and downloading the associated policy file, use the following function to activate the license:

{% code title="activate\_airgap.go" %}

```go
// Complete the activation using the confirmation code and policy file.
ld, err = lh.ActivateAirGapLicense(confirmationCode, policyPath, licenseKey, policyId)
if err != nil {
	fmt.Println("error during air-gap activation:", err)
	return err
}
```

{% endcode %}

### Required Inputs

* `confirmationCode`: Obtained from the Air-Gap Portal.
* `policyPath`: Local path to the policy file (must be included with your application).
* `licenseKey`: Retrieved from License Handler's configuration.
* `policyId`: Found on the LicenseSpring portal and the Air-Gap portal.
* `airgapPublicKey`: The air-gap public key from portal settings.

{% hint style="info" %}
Air-Gap activation uses code exchange only, no file export/import is required. Ensure the policy file is shipped with your software, and confirm you have the correct Air-Gap Public Key from your LicenseSpring settings.
{% endhint %}

## **Step 3: Generate Deactivation Code**

Similar to the activation flow, start by generating a deactivation code using the initialization code from the Air-Gap Portal:

```go
// Generate a deactivation code using the initialization code and license key.
// This code must be submitted to the Air-Gap Portal to receive a confirmation code.
deactivationCode, err := lh.GetAirGapDeactivationCode(initializationCode, licenseKey)
if err != nil {
    fmt.Printf("failed to generate air-gap deactivation code: %v", err)
    return err
}
fmt.Printf("Deactivation Code: %s\n", deactivationCode)
```

* `initializationCode`: Provided by the Air-Gap Portal.
* `licenseKey`: Retrieved from the authentication data provided in configuration.

Print and store the deactivation code. You will paste this back into the Air-Gap Portal to obtain a confirmation code.

## **Step 4: Deactivate License Using Confirmation Code**

After receiving the confirmation code from the portal, complete the deactivation:

```go
// Complete the deactivation using the confirmation code and policy file.
ld, err = lh.DeactivateAirGapLicense(confirmationCode, policyPath, licenseKey, policyId)
if err != nil {
    fmt.Println("error during air-gap deactivation:", err)
    return err
}
```

### Required Inputs:

* `confirmationCode`: Obtained from the Air-Gap Portal.
* `policyPath`: Local path to the policy file (must be included with your application).
* `licenseKey`: Retrieved from the License Handler's configuration.
* `policyId`: Found on the LicenseSpring portal and the Air-Gap portal.


---

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

```
GET https://docs.licensespring.com/sdks/go-sdk/v2/samples/air-gap-license.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
