Skip to content

feat: reuse the saved certificate on email login - #33

Merged
kongesque merged 1 commit into
mainfrom
feat/email-certificate-reuse
Nov 16, 2026
Merged

kongesque merged 1 commit into
mainfrom
feat/email-certificate-reuse

Conversation

@kongesque

@kongesque kongesque commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Issue #31: email login always sent an empty certificate (api.Login(email, password, "")), so every re-login needed a phone PIN even on a device that had completed email login before. The certificate from that earlier login was already saved, just never reused.

  • Sending the saved certificate. line login --email now sends it only when the saved session came from an email login for the same address, was not invalidated, and holds Letter Sealing keys (unless the account has none). QR-origin, legacy, and invalidated certificates are not sent. The PIN-challenge continuation and the non-E2EE (LSOFF) type-0 retry send the same certificate.
  • Keys when LINE skips verification. The PIN step is how the keychain reaches a new client, so a certificate login may return tokens without keys. For the same account, the CLI then loads the saved keys and requires the newest to match negotiateE2EEPublicKey for the account (key ID and public key). A mismatch saves nothing and the error suggests --require-pin. A fresh keychain, when sent, is always exported instead.
  • Certificate retention. If LINE returns no new certificate, the accepted one is kept (same account only).
  • Failures. A failed certificate login says so and suggests --require-pin; it is not repeated without the certificate (AGENTS.md: no automatic retries).
  • --require-pin. New option, valid only with --email, that sends no certificate. Added to help and shell completion.
  • Docs. CLI guide (en/ja/th/zh-TW), a dated issue feat: ✨ Reuse the saved certificate on email login so a known device can skip the PIN #31 section in SESSION.md with the evidence and open questions, and a changelog entry under Unreleased.

Refs #31.

Evidence and what is inferred

No live capture was made. The behavior follows two open-source clients:

  • Beeper f9b620b uses the same Chrome gateway. It sends the saved certificate only when it holds exported keys, keeps those keys when a same-account reply has no keychain, and keeps the old certificate when the reply has none.
  • LINEJS 3c4a4cc uses desktop Thrift clients. It stores the certificate per email and always sends it. Before using stored keys after login, it checks them against the server-registered key and fails rather than registering a new one. The CLI's key check follows this, using negotiateE2EEPublicKey because the CLI has no getE2EEPublicKeys call.

Neither client has a separate path for a rejected certificate: both assume LINE answers a stale certificate with the usual verification challenge, so no fallback request was added. That assumption, and whether the official Chrome extension reuses its certificate on email login, are unverified.

Validation

On macOS arm64 with Go 1.27.4:

  • ./scripts/check-toolchain.sh, ./build.sh, ./bin/line help login, goimports, gofmt, go vet, staticcheck, git diff --check, and ./scripts/security-check.sh ./bin/line (0 reachable vulnerabilities).
  • go test -race ./internal/... ./cmd/line ./pkg/line/... ./pkg/e2ee.
  • New synthetic tests:
    • Session: reuse with checked keys, stale keys not saved, each case where no certificate is sent, a stale certificate getting the PIN flow with fresh keys, a failed certificate login not repeated, the key comparison table, and unreadable saved keys failing before any LINE request.
    • CLI: --require-pin rejected without --email, and the certificate sent by default but not with --require-pin.
  • Not run locally: ./pkg and ./pkg/ltsm (untouched), and the Linux and Windows storage suites (CI).
  • Not tested live. A live check would replace the session used by the ongoing issue bug: 🐛 Token refresh rejected (HTTP 400, gateway 10201) 3–4 days after QR login, well before the ~7-day boundary #29 test, so it waits until after 2026-11-19.
  • The translations haven't had native-speaker review.

Email login always sent an empty certificate, so every re-login needed a
phone PIN. It now sends the certificate saved by an earlier email login
for the same address when that session was not invalidated and holds
Letter Sealing keys, as Beeper and LINEJS do.

If LINE skips verification and returns tokens without a keychain, the
saved keys are reused only when their newest key matches the account's
current key from negotiateE2EEPublicKey; otherwise nothing is saved. The
old certificate is kept when LINE sends none. A failed certificate login
is reported and not repeated. `--require-pin` sends no certificate.

Refs #31
@kongesque
kongesque merged commit 0cb502d into main Nov 16, 2026
8 checks passed
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