Skip to content

BlockPageApp: fix three bugs in Online Certificate Signing#1897

Open
Hemsby wants to merge 2 commits intoTechnitiumSoftware:developfrom
Hemsby:fix/block-page-online-cert-signing
Open

BlockPageApp: fix three bugs in Online Certificate Signing#1897
Hemsby wants to merge 2 commits intoTechnitiumSoftware:developfrom
Hemsby:fix/block-page-online-cert-signing

Conversation

@Hemsby
Copy link
Copy Markdown

@Hemsby Hemsby commented May 3, 2026

Fixes the three bugs reported in #1896.

Missing intermediate certificate in TLS handshake

When a per-domain cert is generated and cached, the SslStreamCertificateContext was created with null for the additional certificates, meaning the signing CA was never included in the TLS handshake. Clients that did not already have the CA cached would get a chain validation error. The CA cert is now passed as the additional certs collection so browsers receive the full chain.

notBefore not clamped to CA own NotBefore

The code backdates generated certs by 30 minutes for clock skew tolerance. If the CA cert was created within the last 30 minutes, this fell before the CA own NotBefore and .NET threw ArgumentException: The requested notBefore value is earlier than issuerCertificate.NotBefore. The exception was caught and logged but the app silently fell back to serving the CA cert directly as the server cert for up to 30 minutes. certNotBefore is now clamped to Max(UtcNow - 30min, caCert.NotBefore).

ECC and ECDSA CA certs not supported

CertificateRequest.Create(X509Certificate2, ...) requires the CA key algorithm to match the CSR algorithm. Since the CSR is always RSA 2048, any ECC CA failed with ArgumentException: The issuer certificate public key algorithm does not match. The X509SignatureGenerator overload is now used, which supports both RSA and ECC CA certs.

Both the self-signed cert path (webServerUseSelfSignedTlsCertificate: true) and the custom CA path are covered by these changes.

@Hemsby Hemsby changed the base branch from master to develop May 3, 2026 14:40
@ShreyasZare
Copy link
Copy Markdown
Member

Thanks for the PR. Will test this soon.

Pass CA cert as additional cert in SslStreamCertificateContext so the
full chain is included in the TLS handshake for per-domain certs.
Previously null was passed, causing chain validation failures on
clients that did not already have the CA cached.

Clamp certNotBefore to the CA cert NotBefore. The code backdates
per-domain certs by 30 minutes for clock skew tolerance, but if the CA
was created within the last 30 minutes this fell before the CA own
NotBefore and threw ArgumentException, silently falling back to
serving the CA cert as the server cert for up to 30 minutes.

Use X509SignatureGenerator overload of CertificateRequest.Create so
that ECC and ECDSA CA certs are supported. The previous overload
required the CA and CSR to use the same key algorithm, so any ECC CA
failed with ArgumentException.
@Hemsby Hemsby force-pushed the fix/block-page-online-cert-signing branch from 6a36a30 to 221df63 Compare May 3, 2026 14:50
…wwwroot

When serveBlockPageFromWebServerRoot is enabled, requests to / and /index.html
were served directly by the static files middleware, bypassing ServeDefaultPageAsync
entirely so {BLOCKING-INFO} was never substituted and the raw placeholder appeared
in the page.

Fix: an interceptor middleware registered before UseStaticFiles catches GET requests
to / and /index.html and routes them through ServeDefaultPageAsync, which now reads
the content from the wwwroot index.html file on disk before performing the substitution.

The default wwwroot/index.html example is updated to include {BLOCKING-INFO} so users
customising the block page can see how to use it.
@Hemsby
Copy link
Copy Markdown
Author

Hemsby commented May 3, 2026

Added an enhancement also, so {BLOCKING-INFO} can be used to show the Blocked reason etc on custom HTML.

<body>
<h1>Website Blocked</h1>
<p>This website has been blocked by your network administrator.</p>
{BLOCKING-INFO}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{BLOCKING-INFO}
{BLOCKING-INFO}

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.

3 participants