<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Velopre</title>
    <description>The latest articles on DEV Community by Velopre (@velopre).</description>
    <link>https://dev.to/velopre</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4243101%2F2ed4c49e-9588-49fd-9681-a4aeac9e8c9a.jpg</url>
      <title>DEV Community: Velopre</title>
      <link>https://dev.to/velopre</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/velopre"/>
    <language>en</language>
    <item>
      <title>Why returning {"valid": true} for desktop license checks is broken (and how signed leases fix it)</title>
      <dc:creator>Velopre</dc:creator>
      <pubDate>Fri, 13 Nov 2026 14:33:09 +0000</pubDate>
      <link>https://dev.to/velopre/why-returning-valid-true-for-desktop-license-checks-is-broken-and-how-signed-leases-fix-it-11i1</link>
      <guid>https://dev.to/velopre/why-returning-valid-true-for-desktop-license-checks-is-broken-and-how-signed-leases-fix-it-11i1</guid>
      <description>&lt;p&gt;If you're shipping a paid desktop app (Electron, Tauri, .NET, Python, etc), please avoid doing basic HTTP checks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://api.myapp.com/verify?key="&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;valid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;unlockApp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I see this all the time, and it takes about 30 seconds to bypass. Anyone can just:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Map your licensing domain to &lt;code&gt;127.0.0.1&lt;/code&gt; in their local hosts file&lt;/li&gt;
&lt;li&gt;Run a 5-line local server that returns &lt;code&gt;{"valid": true}&lt;/code&gt; to any request&lt;/li&gt;
&lt;li&gt;Unlock the app permanently&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;On top of that, if a paying user gets on a flight or has spotty WiFi, the request fails and your app locks them out.&lt;/p&gt;

&lt;p&gt;The real fix isn't heavy DRM or code obfuscation. It's just asymmetric cryptography.&lt;/p&gt;

&lt;p&gt;Instead of sending back plain JSON, your server signs the activation payload (machine identifier, license key, expiration date/lease, and a random nonce) using an Ed25519 private key.&lt;/p&gt;

&lt;p&gt;Your desktop app only ships with the Public Key. When the client receives the payload, it verifies the signature locally.&lt;/p&gt;

&lt;p&gt;Why this works:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Even if a user redirects your licensing URL to localhost, their fake server doesn't have your private key. It physically cannot forge an Ed25519 signature that passes the embedded public key check.&lt;/li&gt;
&lt;li&gt;The random nonce prevents replay attacks (recording a real server response and replaying it later).&lt;/li&gt;
&lt;li&gt;Offline support: once verified, you save the signed payload locally. The app can verify the signature and lease expiration date on every launch completely offline. No startup network latency.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I put together a minimal open-source Electron boilerplate demonstrating the client-side signature verification and offline lease storage:&lt;br&gt;
&lt;a href="https://github.com/velopre/electron-license-key-example" rel="noopener noreferrer"&gt;https://github.com/velopre/electron-license-key-example&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(For context: I got annoyed by this while building desktop software and ended up turning the backend into &lt;a href="https://keyfern.com" rel="noopener noreferrer"&gt;Keyfern&lt;/a&gt;, mainly because legacy licensing platforms start at $199–€299/mo and meter API requests, which makes zero sense when users launch apps offline. Keyfern is free up to 50 keys and $10/mo for 1,000 keys with no API request limits. But regardless of whether you use a service or write 20 lines of libsodium yourself, please stop relying on unsigned JSON responses on client machines.)&lt;/p&gt;

&lt;p&gt;Curious how others here handle machine-locking and clock rollback detection without getting in the way of legitimate users.&lt;/p&gt;

</description>
      <category>electron</category>
      <category>security</category>
      <category>cryptography</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
