Repository navigation
Verify RDP server certificates instead of ignoring them - #10
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Turns RDP server certificate verification on instead of accepting whatever the server presents.
What changed
native/CxRdpBridge/cxrdp_bridge.cpp): the bridge used to forceFreeRDP_IgnoreCertificateandAutoAcceptCertificateto TRUE and answer every certificate hook with accept-and-store. It now registerscxrdp_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.%APPDATA%/FreeRDP/serverwithout calling the hook, so the second connection to a host skipped every check.FreeRDP_ExternalCertificateManagementkeeps 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.Services/RdpCertificateTrustServicepins the SHA-256 fingerprint perhost:portin therdp_certificatescollection, 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 on127.0.0.1.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, includingSshHostKeyTrustServiceTests.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.RDP certificate acceptedand the connection reached logon; with a tampered fingerprint (BlockChanged=true) the TLS handshake was aborted; withBlockChanged=falsethe 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.dllkeeps 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.