1. Choose an offline policy
Use file activation when the customer's computer cannot access the Internet even for its first activation. The authorization policy must allow node-locked offline activation. Floating sessions cannot first activate through this workflow.
Create an export entitlement, select the permitted offline duration and generate product.json with the product's public-key pins. The license key comes from the customer. A timed license starts when the server approves activation, not when the file eventually reaches the offline computer.
2. Install the native SDK
In SDK documentation, choose C or C++, the operating system and the versioned website installer. Link your project using the generated CMake dependency. The native core requires a compatible compiler, libcurl and OpenSSL; C++ needs C++17.
The example below uses licentivo.hpp and the CMake target Licentivo::CPP. The configured package already includes native demo targets. Keep product.json next to the program or pass its absolute path in your application.
For a prebuilt CMake package, use this CMakeLists.txt. Configure with cmake -S . -B build -DCMAKE_PREFIX_PATH=SDK_PREFIX, replacing SDK_PREFIX with the CMake prefix printed by the installer; then run cmake --build build --config Release. For a source package, follow the installer’s add_subdirectory instructions instead of find_package.
cmake_minimum_required(VERSION 3.18)
project(offline_app LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
find_package(Licentivo 0.10 REQUIRED)
add_executable(offline offline.cpp)
target_link_libraries(offline PRIVATE Licentivo::CPP)3. Export and import using the SDK
Save the example as offline.cpp and add it to your SDK-enabled CMake project. Run offline request YOUR_LICENSE_KEY on the offline computer. It produces activation.request.json without opening an online client.
Move that request to a connected computer. In the vendor console or the associated customer's portal, upload the request and download its approved response. Save it as activation.response.json, then return both files to the original computer and run offline import YOUR_LICENSE_KEY.
#include "licentivo.hpp"
#include <fstream>
#include <iostream>
#include <iterator>
#include <stdexcept>
#include <string>
std::string readText(const char* path) {
std::ifstream file(path);
if (!file) throw std::runtime_error("Cannot read file");
return {std::istreambuf_iterator<char>(file), {}};
}
int main(int argc, char** argv) {
try {
// product.json contains public settings; the key is entered by the customer.
if (argc < 3) throw std::runtime_error("Usage: offline request|import LICENSE_KEY");
licentivo::Client client("product.json", argv[2]);
if (std::string(argv[1]) == "request") {
std::ofstream file("activation.request.json");
file << client.OfflineRequest();
if (!file) throw std::runtime_error("Cannot save request");
std::cout << "Created activation.request.json\n";
} else if (std::string(argv[1]) == "import") {
client.ImportOffline(readText("activation.request.json"),
readText("activation.response.json"));
client.RunFeature("export", [] {
std::ofstream file("licensed-report.txt");
file << "Licensed offline export\n";
if (!file) throw std::runtime_error("Cannot save report");
});
std::cout << "Created licensed-report.txt\n";
} else {
throw std::runtime_error("Unknown operation");
}
} catch (const std::exception& error) {
std::cerr << error.what() << '\n';
return 1;
}
}4. Check the result
- Confirm the import succeeds and licensed-report.txt is created.
- Restart using the stored device credential and the same cache location. A still-valid offline lease should allow the entitled feature.
- Try importing on another ordinary computer: device validation should reject that response.
- Check the authorization expiry and offline duration. File import does not extend the original license or permit use beyond its signed limits.
Using the C interface
For a C application, construct an unstarted client with ln_init_file_with_license, generate the request with ln_offline_request, and verify/import with ln_import_offline. Release returned strings with ln_free_string and close with ln_destroy. The configured C demo demonstrates these calls.
Do not call Start or ln_open for the first fully offline activation: those entry points attempt online startup. Do not implement signature parsing in your business code.
Common failures and operational limits
An invalid response can mean the original request, product, device, signing key or application version does not match. Bring the signed response back to the computer that generated its request. Do not edit JSON payloads or disable verification.
An expired request needs a new request and approval. An expired lease needs renewal or another approved file exchange according to the policy. Online metered reserve/commit operations are unavailable while fully offline.
A remote unbind or revocation becomes known on the old device's next online check. A permanently offline device cannot immediately learn a server-side change. Choose the offline duration with that limitation in mind.