Skip to content

feat: ca cert download#240

Open
deblasis wants to merge 12 commits intovercel-labs:mainfrom
deblasis:feat/ca-cert-download
Open

feat: ca cert download#240
deblasis wants to merge 12 commits intovercel-labs:mainfrom
deblasis:feat/ca-cert-download

Conversation

@deblasis
Copy link
Copy Markdown

Summary

  • Add cert.<tld> HTTP endpoint that serves an OS-aware HTML instructions page (detects OS from User-Agent) or a raw PEM download at /download and /ca.pem
  • Add portless cert CLI command that outputs the CA certificate to stdout for piping over SSH (ssh <host> portless cert > portless-ca.pem)
  • Add getCaCert callback to ProxyServerOptions so the cert is available even without TLS enabled

Why

My use case, which this PR solves is the following:

Multi-machine environment. One machine (A) has a webapp that uses portless. Another machine (B) effectively controls A via ssh and conveniently uses port-forwarding to access resources on A, including the aforementioned webapp.

Portless handles the CA management locally on A but in this case, the CA needs to be installed on B.

So, yeah, I built this little thing and functionally it works. Now I can download the cert from B and install it and it works fine.
I am not 100% sure about the UX yet but I am sharing this in case you like the idea and we want to push this down the line together.

Happy to put some neurons and tokens to work to ship it if you like it.

image

There is dark mode as well, don't freak out! 😄

Gotchas

I manage machine A from VSCode/Cursor in B for some design work, so I echo the listening server so that VSCode can pick up the port-forwarding automatically.
It works by pattern matching, so perhaps it could look better with a nicer message, unless you reckon it's just better to drop it entirely and let the user handle it manually.

Test Plan

  • 17 new tests for detectOS and renderCertPage in pages.test.ts
  • 9 new proxy tests for cert endpoint (page, download, 404, TLD handling, query string stripping, TLS fallback)
  • All 346 existing tests continue to pass
  • Type check and lint pass cleanly
  • Manual: visit https://cert.localhost in browser and verify page renders
  • Manual: run portless cert > /tmp/test-ca.pem and verify valid PEM output

deblasis and others added 10 commits April 21, 2026 19:15
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…mmands

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Prints a plain https://127.0.0.1:<port> URL during proxy startup so
VS Code and other IDEs automatically detect and forward the port.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 22, 2026

@deblasis is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@deblasis deblasis changed the title Feat/ca cert download feat: ca cert download Apr 22, 2026
Comment thread packages/portless/src/pages.ts
The substring "win" appears in "darwin", causing macOS clients to be
detected as Windows. Check mac/darwin first and narrow the Windows
check to "windows", "win32", "win64".
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