Repository navigation
feat(tls): trust a server's own key or CA for WebDAV and FTP - #84
Merged
Merged
Conversation
- PinnedKey= (SHA-256 of the server's public key or certificate) accepts exactly that key, self-signed or reached by IP, instead of VerifyTLS=false; it survives renewals that keep the key. A refused certificate prints the PinnedKey= line for the key presented. - CACert= (base64 DER on one line) replaces the public roots for that remote; the IP in a certificate is matched too, which mbedTLS 2.28 never does. - A line that does not parse leaves the remote out at startup rather than falling back to no check. Dropbox, Drive and SMB ignore both. - The configurator has a Server certificate choice per WebDAV/FTP remote, a key field checked like on the 3DS, and a CA file picker read in the tab; import maps the lines back. - INI_MAX_LINE is 16384 on the heap, so a CA certificate fits on a line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes #72.
What
A WebDAV or FTP remote with a certificate of its own (a NAS, self-signed or from a home CA) could only connect with
VerifyTLS=false, which leaves the password and every file open to anyone on the network posing as the server. Two new keys say what to trust instead:PinnedKey=: the SHA-256 of the server's public key, or of its certificate. Exactly that key is accepted, however the certificate was signed and whatever name it carries, which covers a self-signed NAS reached by IP. It survives renewals that keep the key. Accepted forms: hex (colons or spaces allowed), andsha256//<base64>. Commas separate several keys, for a key change in progress.CACert=: the home CA's certificate as base64 DER on one line. It replaces the public roots for that remote and survives every renewal of the server's certificate.When a certificate is refused, the 3DS prints the
PinnedKey=line for the key the server presented, in two lines under 50 columns that join with or without the colon. A saved log keeps it.How
utils/certtrust(host-tested): parsing both keys into aTlsTrust, and the fingerprint lines. It also finds an IPv4 address in a certificate's subject alternative names: mbedTLS 2.28 only compares DNS names, so without thisCACert=could never work for a server reached by IP.Curl::setTrust()._sslContext()hands mbedTLS theCACert=chain instead of the bundle, and always installs_verifyCertificate()throughmbedtls_ssl_conf_verify(). The callback records the presented key's hash. With a pin, it holds back the chain's flags until the server's own certificate (depth 0, always last), then clears them all on a match, or addsBADCERT_OTHERon a mismatch. This relies on libcurl 8.4 settingMBEDTLS_SSL_VERIFY_OPTIONAL, reading the verify result itself and installing no callback of its own, which I checked withobjdump/nm.remoteconfig: a line that doesn't parse leaves the remote out as a startup issue, and never falls back to not checking. Either key overridesVerifyTLS=false, with an issue. With both keys, the pin decides andCACert=is dropped, with an issue. Dropbox, Drive and SMB ignore both keys, with an issue.INI_MAX_LINEgoes from 2048 to 16384, so a CA certificate fits on one line. The buffer is on the heap (INI_USE_STACK=0) rather than 16 KB of the main thread's stack. The inih sources are untouched.pinnedKeyProblem()ininifile.js). A CA file (.pem/.crt/.der) is read in the tab, never uploaded, and converted to the line (caCertFromFile()). Import maps the lines back and reports contradicting or broken ones. The preview shortens aCACert=; the download keeps it whole.testinfra/README.md.Testing
On a 2DS, against vsftpd and Apache WebDAV over HTTPS:
PinnedKey=line was shownPinnedKey=(self-signed)PinnedKey=with one digit changedCACert=of a home CA, server reached by IPCACert=makebuilds clean,make -C testspasses (336, with the newcerttrustsuite), andnode --test tests/configurator/*.test.js tests/worker/*.test.mjspasses.Not covered:
Found along the way, filed separately: #82 (WebDAV: a 403 for
Depth: infinitystops the remote as a failed login) and #83 (a remote whose connection is gone retries every file three times).🤖 Generated with Claude Code