Skip to content

fix: get through the site's firewall, and serialize without reflection - #6

Merged
crazeydave merged 1 commit into
mainfrom
fix/send-a-user-agent
Sep 28, 2026
Merged

crazeydave merged 1 commit into
mainfrom
fix/send-a-user-agent

Conversation

@crazeydave

Copy link
Copy Markdown
Contributor

Found by the first real run against the test site (https://aa-bristol.org/amber), after Freedom 0.1.0 was deployed there.

SiteGround's firewall refuses the first TLS handshake that .NET's managed handler makes in a process with an HTML 403. Later connections resume the session and pass.

  • This is deterministic: request 1 is refused, requests 2 and 3 pass.
  • WinHTTP and Android's native handler are never refused.

The fix:

  • A 403 whose body is not JSON is retried twice, for any request; it never reached WordPress. A JSON 403 is the plugin refusing and is never retried. This is integrity-sharp's rule for the same host.
  • Every request asks for its connection to be closed (Connection: close). Otherwise the retry reuses the refused connection and is refused again.
  • UseFreedom sends through AndroidMessageHandler, as Link does.
  • Every request carries a User-Agent. Under UseFreedom it starts with the app's own name and version.

The proxy also drops If-None-Match, so the manifest request sends the ETag as ?etag= too. The plugin side is in bleedingdeacons/freedom.

JSON is source-generated. A .NET 10 file-based app threw "Reflection-based serialization has been disabled" on its first request, and trimmed or AOT builds would too. FreedomStateJson now serves the MAUI stores and the example CLI.

End to end against the test site, with the library's default client and a code minted server-side (Google sign-in needs a person):

  • start: 200
  • exchange: 201 (tablet 1)
  • manifest: smtp.host v1, smtp.password v2 secret
  • the plain value came back as sent
  • the sealed secret opened in C# and matched

80 tests and 34 scenarios pass; formatting is clean; the MAUI adapter builds for Android.

The first live run against the test site found SiteGround's firewall refusing the first TLS handshake .NET's managed handler makes per process, and its proxy dropping If-None-Match; and the client threw where reflection-based JSON is off (file-based apps, trimmed/AOT builds). Retries a firewall's HTML 403 on a fresh connection, sends a User-Agent, uses AndroidMessageHandler under UseFreedom, sends the ETag as ?etag= too, and source-generates all JSON with FreedomStateJson for stores.
@crazeydave
crazeydave merged commit 6e28346 into main Sep 28, 2026
6 checks passed
@crazeydave
crazeydave deleted the fix/send-a-user-agent branch September 28, 2026 20:53
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