macOS: TLS Client Certificate selection fails with "Could not access the selected certificate file"
⚠️ Before submitting, please verify the following: ⚠️
- [x] This is a bug, not a question or a configuration issue.
- [x] This issue is not already reported on Github (I have searched for it).
- [x] Nextcloud Server and Desktop Client are up to date. See Server Maintenance and Release Schedule and Desktop Releases for supported versions.
- [x] I agree to follow Nextcloud's Code of Conduct
Bug description
I have configured the reverse proxy (nginx/1.31.8) serving my Nextcloud server (Nextcloud 35.0.2) to require a client certificate. Theoretically, the desktop client (35.0.0) supports this, but on macOS (27.0.1) it seems to cause a permission issue, resulting in the error "Could not access the selected certificate file".
Steps to reproduce
- Set up a Nextcloud server behind client auth (usually with a reverse proxy)
- Create a client certificate (.p12) for auth (optionally: test access with a browser to check setup)
- Set up Nextcloud on macOS, enter the server URL, and click
Log in - Click
Use client certificate - Click
Chooseand select the.p12file created in step 2 from the file dialog. - The error is shown.
Expected behavior
The .p12 file is imported.
Which files are affected by this bug
none
Operating system
macOS
Which version of the operating system you are running.
27.0.1
Installation method
Official Installer for macOS 13 and later
Nextcloud Server version
35.0.2
Nextcloud Desktop Client version
35.0.0
Did this occur after an update or on a clean installation?
Clean desktop client installation
Are you using the Nextcloud Server Encryption module?
No
Are you using an external user-backend?
- [x] Default internal user-backend
- [ ] LDAP or Active Directory
- [ ] SSO - SAML
- [ ] Other
Nextcloud Server logs
Additional info
Root cause
Using Opus 5.5, I traced this to MacSandboxSecurityScopedAccess (src/common/macsandboxsecurityscopedaccess.mm), which converts a QUrl to a local path (line 35), then to an NSUrl (line 42), and checks its access scope (line 50). However, a fresh NSUrl created from a file path never carries a security scope, so the sandboxed app rejects every file.
Client log (redacted)
Relevant line:
[ warning nextcloud.common.mac.sandbox /Volumes/builds/42361/macos-42361/src/common/macsandboxsecurityscopedaccess.mm:55 ]: Failed to start accessing security-scoped resource: "/Users/<user>/mac.p12"
Fix/PR
I have a fix and will open a PR.
Idem here, waiting the fix! Thanks Kall