[Bug] HTTPS-enforcement scenarios fail when Connect / Package Manager terminate TLS on their own port
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Read cross_product/test_ssl.py and security/test_https.py, then compare how request_http and make_http_request classify HTTP responses with the existing helper tests in selftests/test_ssl_helper.py and selftests/test_https_helper.py. Add focused cases for the documented TLS rejection response and unrelated 400 responses. Done means the known plaintext-on-TLS response is accepted as HTTPS enforcement while unrelated 400 and 200 responses still fail the relevant assertions.
Written by the indexing model from the issue text.
Description
VIP version
Seen live with posit-vip 2026.11.2. Reproduced against the v2026.12.0 source (1a54f5f4). The step logic in both files is unchanged on main.
Affected area
Cross-product tests (cross_product/test_ssl.py) and security tests (security/test_https.py)
What happened?
On a deployment where Connect and Package Manager terminate TLS themselves, four scenarios fail:
cross_product/test_ssl.py::test_http_redirects_to_https_for_product[Connect]and[Package Manager]security/test_https.py::test_product_enforces_https[Connect]and[Package Manager]
Here "terminate TLS themselves" means [HTTPS] Listen = :3939 / :4242, with no plain-HTTP listener on those ports.
Both make_http_request and request_http build the HTTP URL by swapping the scheme and keeping the port. So https://connect.example.com:3939 becomes http://connect.example.com:3939, and the plaintext request lands on the TLS listener.
Connect and Package Manager serve TLS with Go's net/http. On a TLS listener, Go answers a plaintext request with a valid HTTP response, not a reset (src/net/http/server.go, c.serve, the tls.RecordHeaderError / tlsRecordHeaderLooksLikeHTTP branch):
HTTP/1.0 400 Bad Request
Client sent an HTTP request to an HTTPS server.
httpx parses that as an ordinary response, so neither function reaches its httpx.NetworkError / httpx.ProtocolError branch. The code comments there describe that branch as "what a plaintext HTTP request gets back from a TLS-only port". The assertions then see a non-3xx status:
make_http_request -> {'status': 400, 'location': '', 'refused': False}
AssertionError: HTTP request was not refused or redirected (got HTTP 400). HTTPS is not enforced.
request_http -> {'status': 400, 'location': '', 'final_url_scheme': 'http', 'error': None}
AssertionError: HTTP did not redirect to HTTPS. Initial response: HTTP 400, Location: '', final URL scheme after following redirects: 'http'
The products are enforcing HTTPS. Nothing is served over plaintext, and http_port_no_content passes on the same response. They also cannot redirect on that port. Both products document HTTP→HTTPS redirection as a separate listener ([HTTPRedirect] Listen = :80). HTTPS.Permanent only adds HSTS and the secure cookie flag. References: Connect HTTPRedirect, Connect HTTPS, Package Manager HttpRedirect, Package Manager SSL.
So a deployment that follows the docs is reported as "HTTPS is not enforced". In the same run, Workbench on :443 with a :80 redirect passes both scenarios.
What did you expect to happen?
A TLS-only port that rejects plaintext with Go's 400 should be classified like the refused/reset case (refused: True / error: "port_closed"). Both scenarios should then pass for Connect and Package Manager on :3939 / :4242.
Steps to reproduce
No Posit product needed. Run a 12-line Go TLS listener and call VIP's own step functions against it.
main.go:
package main
import (
"log"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("ok\n")) })
log.Fatal(http.ListenAndServeTLS("127.0.0.1:18443", "cert.pem", "key.pem", nil))
}
openssl req -x509 -newkey rsa:2048 -nodes -keyout key.pem -out cert.pem -days 1 \
-subj /CN=localhost -addext subjectAltName=DNS:localhost,IP:127.0.0.1
printf 'module repro\ngo 1.27\n' > go.mod && go build -o tlsonly . && ./tlsonly &
curl -s http://127.0.0.1:18443/ # -> Client sent an HTTP request to an HTTPS server.
test_repro.py, run from an empty dir containing a bare pytest.ini ([pytest]):
import types
URL = "https://127.0.0.1:18443"
def cfg(url):
pc = types.SimpleNamespace(is_configured=True, url=url)
return types.SimpleNamespace(verify=False, product_config=lambda key: pc)
def test_security_https_enforced():
from vip_tests.security.test_https import make_http_request, https_enforced
https_enforced(make_http_request(URL, cfg(URL)))
def test_ssl_redirects_to_https():
from vip_tests.cross_product.test_ssl import request_http, redirects_to_https
redirects_to_https(request_http("Connect", cfg(URL)))
def test_ssl_http_port_no_content():
from vip_tests.cross_product.test_ssl import request_http, http_port_no_content
http_port_no_content(request_http("Connect", cfg(URL)))
uv run --no-project --with /path/to/vip python -m pytest -p no:vip -q -rA test_repro.py
# FAILED test_security_https_enforced - AssertionError: HTTP request was not refused or redirected (got HTTP 400) ...
# FAILED test_ssl_redirects_to_https - AssertionError: HTTP did not redirect to HTTPS. Initial response: HTTP 400 ...
# PASSED test_ssl_http_port_no_content
Relevant logs or output
Live vip verify --basic (2026.11.2), on one host running all three products: 4 failed, 65 passed, 26 skipped. The four failures are exactly the scenarios above, with the same assertion messages. A plain curl http://<host>:3939/ and curl http://<host>:4242/ both return Client sent an HTTP request to an HTTPS server.
Environment
- Live:
- Ubuntu 24.04, publicly trusted certificates.
- Workbench 2026.11.1 on
:443, with a:80redirect. - Connect 2026.11.1 with
[HTTPS] Listen = :3939and noHTTP.Listen. - Package Manager 2026.11.2 with
[HTTPS] Listen = :4242and[HTTP] Listen =(empty).
- Repro: Go 1.27.4, Python 3.15, VIP source
1a54f5f4.
Suggested fix
The comments in request_http and make_http_request say to keep the two in sync. In both, classify the response as refused / port_closed when it is a 400 carrying a known plaintext-on-TLS signature.
Keep it as narrow as #457 / #555 intended: match the server's signature, not any 400. A 400 for any other reason should still fail.
_PLAINTEXT_ON_TLS = (
b"Client sent an HTTP request to an HTTPS server", # Go net/http: Connect, Package Manager
b"The plain HTTP request was sent to HTTPS port", # nginx 497 -> 400 page
)
def _rejected_plaintext_on_tls(resp: httpx.Response) -> bool:
return resp.status_code == 400 and any(sig in resp.content for sig in _PLAINTEXT_ON_TLS)
The nginx string is from ngx_http_special_response.c (ngx_http_error_497_page). I only hit the Go case. Nothing here tested Workbench serving TLS on a non-default port.
request_http could report a distinct reason such as "tls_only" instead of reusing port_closed. The report would then say the TLS port rejected plaintext rather than "port closed".
Selftests can follow the existing monkeypatch.setattr(httpx, "get", fake_get) pattern in selftests/test_https_helper.py and the #555 block in selftests/test_ssl_helper.py:
httpx.Response(400, content=b"Client sent an HTTP request to an HTTPS server.\n")→ refused / passes;- a 400 with an unrelated body → still fails;
- a 200 → still fails
http_port_no_content.
Related: #457 and #555 narrowed this exception handling. #546 (TLS in CI) would exercise this path if the product terminates TLS itself.
- Dominant language
- Python
- Stars
- 9
- Forks
- 1
- Avg merge
- 15h 31m
- Merged PRs (30d)
- 44
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from posit-dev/vip
-
team: workbench
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
nightly-failure
Difficulty 4/5 1-2 days Newbie friendliness 25/100
Maintainers usually reply within 1 day
-
nightly-failure
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
tracking
Difficulty 5/5 Over a week Newbie friendliness 25/100
Maintainers usually reply within 1 day
Similar issues
-
jira: an unquoted JQL number of more than 4300 digits is a plain-text 500, where real answers 200Openfidelity
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
A JSON chat answer blocks the backend event loop for the whole RAG runPossibly taken @NopeCharon claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
The-OpenROAD-Project/ORAssistant#656 ·
Maintainers usually reply within 1 day
-
bug(operator): VolterraOperator built inside jax.jit with a concrete decay raises TracerBoolConversionErrorPossibly taken @jejjohnson claimed this today. Opentype:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jejjohnson/integrix#144 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
finos/ai-governance-framework#459 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
autowarefoundation/autoware_carla_scenario#2963 ·
Maintainers usually reply within 1 day