Hi,
I have a macOS Intel machine running Ventura 13.7.4. This machine is used as a build node for Jenkins to run a test for a USB device that has an HID interface. The test runner for this is Java's junit on Azul's Zulu JDK 8 for mac. I've added the com.apple.security.device
entitlement to this JDK 8 bundle and signed using a self-signed certificate. This certificate is available in the system keychain at:
keychain: "/Library/Keychains/System.keychain"
version: 256
class: 0x80001000
On my personal account on this machine, I can run the test and it calls IOHIDDevicePlugin
's open
function and returns success:
[junit] [debug] [hid.cpp:1457] HIDAccess::Open Success in open for cDeviceHandle: 0x6000006abb38
If I run the same test logged in as the Jenkins agent account, then open
returns:
[junit] [debug] [hid.cpp:1484] Could not open HID with handle: 0x600002a5c018, error (-1ffffd3f): (iokit/common) privilege violation
I can see the certificate that signed the JDK bundle running the command:
security find-certificate -c "java-rt-usb" -a -m
The results are the same for both accounts. Is my setup expected to work? I.e. create a self-signed cert in one account with admin privileges, put the cert in the system keychain, sign an app bundle with a new usb entitlement using this cert, and then run that app in another account on the same machine. If it's expected to work, are there any more troubleshooting tools I can use?
ioreg shows the same output for these devices under test in both accounts:
$ ioreg -p IOUSB -w0
+-o CMSIS-DAP@14620000 <class AppleUSBDevice, id 0x1000026ae, registered, matched, active, busy 0 (1 ms), retain 17>
+-o CMSIS-DAP@14630000 <class AppleUSBDevice, id 0x1000026d6, registered, matched, active, busy 0 (1 ms), retain 17>
FYI, self-signed certificates aren’t really useful for code signing on macOS. They are better than ad hoc signing, but not much. My advice is that you use Apple Development signing identities for development code.
Also, the com.apple.security.device
entitlement isn’t a thing. There are two groups of entitlements relevant in this context:
-
App Sandbox entitlements
-
Hardened Runtime entitlements
The first only relevant if you’ve explicitly enabled App Sandbox. The second is relevant to all programs, because all programs should have the hardened runtime enabled. However, for testing purposes you can opt out of the hardened runtime, which disables all of its additional security checks.
Regardless, neither page list com.apple.security.device
.
For HID devices there is an old school com.apple.security.device.hid
entitlement, but it’s been deprecated in favour of com.apple.security.device.usb
, documented here. And both of those are for App Sandbox.
Honestly, I don’t think this that any of the above is relevant to your current issue. Rather, I’d focus on this:
If I run the same test logged in as the Jenkins agent account, then open [fails]
My experience with third-party CI systems is that they tend to run programs in weird execution contexts. For example, they might switch the BSD execution context but not the macOS-specific stuff. See TN2083 Daemons and Agents for more about this concept.
So, when you say that you’re running the test logged in as the Jenkins agent, are you actually logged in? Or relying on Jenkins to log you in?
And, if use the login window to log in as the Jenkins user account on the GUI, does your program work?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"