Repository navigation
feat: reuse the saved certificate on email login - #33
Merged
Merged
Conversation
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
This was referenced Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.line login --emailnow 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.negotiateE2EEPublicKeyfor 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.--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.Refs #31.
Evidence and what is inferred
No live capture was made. The behavior follows two open-source clients:
f9b620buses 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.3c4a4ccuses 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, usingnegotiateE2EEPublicKeybecause the CLI has nogetE2EEPublicKeyscall.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.--require-pinrejected without--email, and the certificate sent by default but not with--require-pin../pkgand./pkg/ltsm(untouched), and the Linux and Windows storage suites (CI).