Skip to content

feat: verify offline licenses locally (VerifyOfflineLicense) - #4

Merged
catsika merged 1 commit into
mainfrom
feat/offline-verifier
Oct 26, 2026
Merged

catsika merged 1 commit into
mainfrom
feat/offline-verifier

Conversation

@catsika

@catsika catsika commented Oct 26, 2026

Copy link
Copy Markdown
Member

What this adds

  • VerifyOfflineLicense(license, OfflineVerifyOptions): verifies a signed .lic file (or bare token) locally with crypto/ed25519 and crypto/x509. No new dependencies.
  • OfflineLicense result, *OfflineLicenseError with eight exported reason codes (OfflineMalformed ... OfflineExpired, string values as in the spec), and ErrInvalidOfflineOptions for bad options, so callers can tell the two apart with errors.As / errors.Is.
  • OfflineKeyID(pem): the key ID Keymint computes for a public key.
  • Re-exports from the deprecated /src package; CI's consumer build compiles both paths.
  • README "Offline Licenses" section.

Spec

Follows the shared offline-verifier spec (same nine ordered checks as the other SDKs) and passes all 34 shared fixtures (testdata/offline-license-fixtures.json, copied unchanged). ProductID and MachineCode are required: one signing key covers every product in an org, so skipping the product check would let a license for one product unlock another (L-04).

Tests

  • TestVerifyOfflineLicenseFixtures: table test over all 34 cases (codes and every license field).
  • TestVerifyOfflineLicenseOptionErrors: no keys, garbage/non-Ed25519 PEM, empty product/machine, skew out of range; skew 0 and 1h accepted.
  • Live test now verifies the file returned by SignKey when KEYMINT_TEST_PUBLIC_KEY (repository variable, PEM) is set; skipped otherwise. Wired into the live job's env. The contract-test filter in CI now includes TestVerifyOfflineLicense.

Local: gofmt -l . clean, go vet ./... clean, go test ./... passes.

Add VerifyOfflineLicense, which checks a signed .lic file (or bare token)
against trusted Ed25519 public key PEMs with the standard library only.
ProductID and MachineCode are required, so a license for one product
cannot unlock another under the shared org signing key (L-04).

Failures return *OfflineLicenseError with one of eight reason codes; bad
options wrap ErrInvalidOfflineOptions. Also adds OfflineKeyID, re-exports
from the deprecated /src package, the shared 34-case fixture file with a
table test, a live check of the signed file when KEYMINT_TEST_PUBLIC_KEY
is set, and a README section.
@catsika
catsika merged commit 88e6886 into main Oct 26, 2026
2 checks passed
@catsika
catsika deleted the feat/offline-verifier branch October 26, 2026 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant