feat: auto-generate certificates and show error details#5
Merged
Conversation
- Add CertManager to auto-generate TLS certificates using bundled mkcert - Bundle mkcert binaries for macOS (arm64/x64) - Generate certificates when Base Domain is saved in Settings - Show error message in UI when proxy fails to start - Fix proxy restart to properly close connections before restarting - Store certificates in ~/Library/Application Support/dev-proxy/certs/ Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add try-catch to installCA() with descriptive error message - Add try-catch to generateCert() with descriptive error message - Add try-catch to ensureCert() call in ipc-handlers.ts Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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
Changes
CertManagerクラスを追加(証明書の確認・生成)stop()でcloseAllConnections()を使用して確実に接続を閉じるTest plan
🤖 Generated with Claude Code
Greptile Summary
このPRは、証明書の自動生成機能とエラーメッセージUI表示機能を追加する重要な改善。Settings で Base Domain を保存すると mkcert を使って自動的にワイルドカード証明書が生成され、ユーザーが手動で証明書を用意する手間を省く。また、プロキシ起動時のエラーをUIに表示するようになり、ユーザーエクスペリエンスが大幅に向上。
主な変更点:
CertManagerクラスを新規作成し、mkcert バイナリの実行、CA確認、証明書生成をカプセル化ipc-handlers.ts:47-54)ProxyStatusPayloadで伝達し、UIに表示(renderer/main.ts:412-423)closeAllConnections()を使用して接続を確実にクローズ(proxy-server.ts:214-224)懸念点:
ipc-handlers.ts:47-54でensureCert()のエラーハンドリングが不足。証明書生成失敗時(特にユーザーが sudo パスワード入力をキャンセルした場合)にユーザーに分かりやすいエラーが表示されないcloseAllConnections()の Node.js バージョン互換性確認が必要Confidence Score: 4/5
src/main/ipc-handlers.tsのエラーハンドリングに注意が必要Important Files Changed
Sequence Diagram
sequenceDiagram participant User participant Renderer participant IPC participant CertManager participant ProxyServer participant mkcert Note over User,mkcert: Settings保存時の証明書自動生成フロー User->>Renderer: Base Domainを入力して保存 Renderer->>IPC: config:set (base_domain) IPC->>CertManager: checkCertExists(baseDomain) CertManager-->>IPC: { exists: false } alt 証明書が存在しない IPC->>CertManager: ensureCert(baseDomain) CertManager->>CertManager: isCAInstalled() CertManager->>mkcert: -CAROOT mkcert-->>CertManager: CA root path alt CAが未インストール CertManager->>mkcert: -install (sudo required) mkcert-->>User: sudoパスワード要求 User-->>mkcert: パスワード入力 mkcert-->>CertManager: CA installed end CertManager->>mkcert: *.{baseDomain} mkcert-->>CertManager: 証明書生成完了 CertManager-->>IPC: CertPaths end IPC->>Renderer: 保存完了 Renderer->>IPC: restartProxy() IPC->>ProxyServer: restart() Note over ProxyServer: プロキシ再起動フロー ProxyServer->>ProxyServer: stop() alt サーバーが稼働中 ProxyServer->>ProxyServer: closeAllConnections() ProxyServer->>ProxyServer: httpServer.close() ProxyServer->>ProxyServer: httpsServer.close() ProxyServer->>ProxyServer: cleanup() end ProxyServer->>ProxyServer: start() ProxyServer->>CertManager: checkCertExists(baseDomain) CertManager-->>ProxyServer: { exists: true, paths } alt 証明書が存在しない ProxyServer->>ProxyServer: setStatus('error', message) ProxyServer->>Renderer: proxy:status (error + message) Renderer->>User: エラーメッセージを表示 else 証明書が存在する ProxyServer->>ProxyServer: 証明書を読み込み ProxyServer->>ProxyServer: HTTPサーバー起動 ProxyServer->>ProxyServer: HTTPSサーバー起動 ProxyServer->>ProxyServer: setStatus('running') ProxyServer->>Renderer: proxy:status (running) Renderer->>User: Status: Running end