# Offline license activation

Licensing Diffblue Cover in the offline mode detailed here is available **only** when purchased with the [Enterprise Edition](/updates-and-upgrades/cover-editions.md) offline option. To use Diffblue Cover in an offline environment, such as a high-security or air-gapped network, requires this [Enterprise Edition](/get-started/licensing.md#editions) offline option.

Otherwise Diffblue Cover requires a [remote license check](/get-started/licensing/licensing-online.md) with the Diffblue licensing server each time it is used.

## Activating an offline license

This section describes how to activate a Diffblue Cover offline license.

{% tabs %}
{% tab title="Cover Plugin" %}
Licensing the Diffblue Cover Plugin for IntelliJ in offline mode is performed using Cover CLI.

1. Install [Diffblue Cover Plugin](/get-started/get-started/get-started-cover-plugin.md) and install [Diffblue Cover CLI](/get-started/get-started/get-started-cover-cli.md).
2. Before entering a license key, completely exit all instances of the IntelliJ IDE. Note that closing the project window is not sufficient.
3. Follow the Cover CLI steps detailed in the tab above to activate your license in offline mode, using the Diffblue Cover CLI command `dcover activate --offline`
4. Restart the IntelliJ IDE.
5. You're now ready to write tests using Diffblue Cover Plugin.
   {% endtab %}

{% tab title="Cover CLI" %}
Activating Diffblue Cover CLI offline:

1. Install [Diffblue Cover CLI](/get-started/get-started/get-started-cover-cli.md).
2. Obtain your licence file and license key. To activate Diffblue Cover offline you will require your license file `ls_activation.lic`, along with your license key `XXXX-XXXX-XXXX-XXXX`. These can be obtained from:\
   \- Your Diffblue Cover welcome email received following license purchase.\
   \- Your organization's internal file/app/license store.\
   \- Or contact [Diffblue Support](https://www.diffblue.com/support) for help finding this information.
3. Run `dcover license` to prepare a directory for license installation:

```
➜  dcover license

12:55:23.365 INFO  Diffblue Cover 2022.02.02
12:55:23.368 INFO  There is no license linked to your product
```

This will create an `offline` directory at:

```
<USER_HOME>/.diffblue/offline/
```

4. Copy `ls_activation.lic` to the Diffblue offline license directory:
5. On Linux or macOS your home directory can be found at `~/.diffblue/offline/`
6. On Windows your user home can be found at `C:\Users\<username>\.diffblue\offline\`
7. Run `dcover activate --offline <license key>` to install the offline license:

```
➜  dcover activate --offline XXXX-XXXX-XXXX-XXXX

15:48:35.064 INFO  Found an offline license file at '<USER_HOME>/.diffblue/offline/ls_activation.lic'
15:48:35.494 INFO  Successfully activated offline license
```

6. You're now ready to write tests using Diffblue Cover CLI.
   {% endtab %}

{% tab title="Environment Variables (CLI and CI)" %}
Diffblue Cover CLI (also as used in Docker images and Diffblue Cover Pipelines) can be configured using environment variables. Please note that environment variables for offline license activation will not work for the plugin.

Obtain your license file and license key. To activate Diffblue Cover offline you will require your license file `ls_activation.lic`, along with your license key `XXXX-XXXX-XXXX-XXXX`. These can be obtained from:\
\- Your Diffblue Cover welcome email received following license purchase.\
\- Your organization's internal file/app/license store.\
\- Or contact [Diffblue Support](https://www.diffblue.com/support) for help finding this information.

Configure the following environment variables:

* `DIFFBLUE_OFFLINE_LICENSE_ACTIVATION_FILE_CONTENTS` with the contents of the `ls_activation.lic`
* `DIFFBLUE_LICENSE_KEY` with the value of your license key.

*Windows only note:* due to Windows environment variable size limitations (e.g. cmd.exe, Windows system variables, etc.), please configure using PowerShell to ensure the license activation file environment variable can be stored. Note that third party software such as git bash usually support larger environment variables.

You can now activate your license with

```
dcover activate --offline
```

{% endtab %}
{% endtabs %}

## Distributing an offline license

This section describes how to make an offline Enterprise license for Diffblue Cover available to users without them requiring their own activation or access to the license key. This is typically useful when users have managed environments where new software can be rolled out to their environment, or as an alternative to environment variables in a CI environment.

1. First, the license will need to be activated as above using the Diffblue Cover CLI and provided `ls_activation.lic` and license key, e.g.:\
   `dcover activate --offline <DIFFBLUE LICENSE KEY>`\
   this will put a `license.key` file into `<USER_HOME>/.diffblue/`.
2. The `license.key` file above can now be placed into the `<USER_HOME>/.diffblue` directory of any user and this will be recognized by Diffblue Cover (Plugin and CLI).


---

# Agent Instructions: 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://cover-docs-preview.diffblue.com/get-started/licensing/licensing-offline.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.
