Best Practices

Guidelines for effective implementation and security

Implementation Strategy

Key Principle: Fail Gracefully

Always design your kill-switch to fail in a way that maintains customer trust.

1. Choose the Right Failure Mode

Fail-Open (Recommended)

Allow access when checks fail. Best for maintaining customer relationships.

  • Show upgrade prompts
  • Limit premium features
  • Continue basic functionality

Fail-Closed (Strict)

Block access when checks fail. Use only for high-security scenarios.

  • Complete application shutdown
  • Hard license enforcement
  • High-security requirements

2. Cache Strategically

CacheTtlMinutes: 60 (Recommended)

  • Low TTL (1-15 minutes): High security, frequent checks
  • Medium TTL (30-60 minutes): Balanced approach
  • High TTL (2-24 hours): Better performance, less security

Security Best Practices

1. API Key Management

Never commit API keys to version control

  • Use environment variables
  • Implement key rotation (every 90 days)
  • Use different keys for different environments
  • Monitor key usage in dashboard

2. Code Obfuscation

Make reverse engineering difficult:

// Good: Innocent-looking code

var analytics = AnalyticsClient.Initialize();

await analytics.ValidateLicenseAsync();


// Avoid: Obvious kill-switch code

var killSwitch = KillSwitchClient.Create();

if (!await killSwitch.CheckAsync()) Exit();

Integration Patterns

1. Application Startup

// .NET Console Application

public static async Task Main(string[] args)

{

var licenseCheck = await LicenseValidator.ValidateAsync();

if (!licenseCheck.IsValid)

return ShowTrialExpiredMessage();

await RunApplicationAsync();

}

2. Periodic Checks

// Background service for long-running apps

public class LicenseMonitor : BackgroundService

{

protected override async Task ExecuteAsync(CancellationToken stoppingToken)

{

while (!stoppingToken.IsCancellationRequested)

await ValidateLicensePeriodically();

await Task.Delay(TimeSpan.FromHours(1), stoppingToken);

}

}

Customer Experience

1. Graceful Degradation

✅ Good Experience

  • "Your trial has ended. Upgrade to continue."
  • Show upgrade options
  • Allow basic functionality
  • Provide support contact

❌ Poor Experience

  • "Access denied. Contact administrator."
  • Immediate application exit
  • No explanation or help
  • Technical error messages

2. Communication Strategy

  • Before expiration: Send renewal reminders
  • At expiration: Show clear upgrade paths
  • After expiration: Provide grace periods when possible
  • Support: Make it easy to contact support

Monitoring and Analytics

1. Dashboard Monitoring

  • Monitor daily check counts
  • Track blocked attempts
  • Set up alert thresholds
  • Review customer activity

2. Logging Strategy

// Log license check events

logger.LogInformation("License check for {CustomerId}: {Status}",

customerId, result.Allowed ? "Allowed" : "Blocked");

3. Performance Considerations

Scenario Recommended TTL Network Calls
Desktop Application 2-4 hours ~6-12 per day
Web Application 15-30 minutes ~48-96 per day
Mobile Application 1-2 hours ~12-24 per day

Ready to Implement?

Start with our recommended settings and adjust based on your specific needs.