Skip to content

Verify RDP server certificates instead of ignoring them - #10

Merged
xiaochengzjc merged 1 commit into
masterfrom
feat/rdp-cert-verify
Nov 29, 2026
Merged

xiaochengzjc merged 1 commit into
masterfrom
feat/rdp-cert-verify

Conversation

@xiaochengzjc

@xiaochengzjc xiaochengzjc commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Turns RDP server certificate verification on instead of accepting whatever the server presents.

What changed

  • native (native/CxRdpBridge/cxrdp_bridge.cpp): the bridge used to force FreeRDP_IgnoreCertificate and AutoAcceptCertificate to TRUE and answer every certificate hook with accept-and-store. It now registers cxrdp_set_certificate_callback (API 16, CX_RDP_CAPABILITY_CERTIFICATE_VERIFICATION) and returns the host decision, so a rejected fingerprint aborts the handshake. The X509 path computes the SHA-256 digest itself, the digest is normalised to lower case, and one decision is cached per fingerprint so a TLS + NLA/CredSSP exchange prompts once.
  • FreeRDP certificate store: FreeRDP answers a matching host from %APPDATA%/FreeRDP/server without calling the hook, so the second connection to a host skipped every check. FreeRDP_ExternalCertificateManagement keeps every connection going through the callback, and the stored entry for the endpoint is removed before connecting as a fallback for builds that ignore that flag.
  • managed: Services/RdpCertificateTrustService pins the SHA-256 fingerprint per host:port in the rdp_certificates collection, with first-use prompting, one-time trust and change blocking. Sessions through an SSH tunnel or proxy relay key the store on the real target (_profileCacheHost / _profileCachePort), not on 127.0.0.1.
  • UI: RdpCertificatePromptWindow (common name, issuer, fingerprint and the saved fingerprint side by side), an RDP section in Settings, and a trusted-certificate list on the Trusted hosts page with removal.

Defaults follow SSH: ConfirmRdpCertificateOnFirstConnection=true, BlockChangedRdpCertificates=true. A changed certificate is rejected without a prompt - the operator removes the entry in Settings, exactly like the SSH host key model.

Verification

  • dotnet build -c Release (.NET 11.0.100): 0 warnings, 0 errors.
  • dotnet test: 769 passed, 7 failed. The pre-existing environment failures on this machine are SQLite persistence tests, including SshHostKeyTrustServiceTests.PermanentTrust_PersistsAndSkipsFuturePrompt, which fails without these changes; the two new failures are the same write-then-read-through-a-second-instance pattern and should pass in CI.
  • native bridge compiled with MSVC 19.44 against FreeRDP 3.26 and OpenSSL 3.6 from vcpkg.
  • End-to-end against a real self-signed RDP host: first connect was rejected with the digest logged; after pinning, RDP certificate accepted and the connection reached logon; with a tampered fingerprint (BlockChanged=true) the TLS handshake was aborted; with BlockChanged=false the changed-certificate prompt was raised and a rejection aborted the connection again.

Compatibility

The native API version goes 15 to 16 and the capability bit is new, so an older CxRdpBridge.dll keeps the previous accept-all behaviour (the managed side only registers the callback when both are present). A newer DLL paired with an older host also keeps it, because the bridge only turns verification on when a callback is registered.

The bridge used to set FreeRDP_IgnoreCertificate and
AutoAcceptCertificate to TRUE and answered every certificate hook with
"accept", so a self-signed certificate from anyone on the path was
accepted without a word. It now asks the host through
cxrdp_set_certificate_callback (API 16) and answers with the host's
decision, which aborts the connection when the fingerprint is rejected.

FreeRDP keeps accepted certificates in its own store and answers a
matching host from there without calling the hook at all, which made the
second connection to a host skip every check - including a rotated
fingerprint. Declaring the certificate management as external keeps each
connection going through the callback, and the store entry for the
endpoint is dropped before connecting as a fallback for builds that
ignore that flag.

The managed side pins the SHA-256 fingerprint per host:port in the
rdp_certificates collection, prompts on first use and blocks a changed
fingerprint until the operator removes the entry in Settings -> Trusted
hosts, mirroring the SSH host key model. Sessions through a tunnel or
proxy relay key the store on the real target instead of 127.0.0.1.
@xiaochengzjc
xiaochengzjc merged commit 1cb5a98 into master Nov 29, 2026
1 check passed
@xiaochengzjc
xiaochengzjc deleted the feat/rdp-cert-verify branch November 29, 2026 09: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