---
title: "Signing"
description: "Code signing, entitlements and provisioning profiles, keychain access and the prompts macOS shows."
---

```sh
swift package --allow-writing-to-package-directory --allow-network-connections all \
    cef bundle --product MyApp --sign "Apple Development"
```

## Code signing

### Identity

The identity is, in order of precedence:

1. `--sign <identity>`, or `--sign -` for ad hoc.
2. `signingIdentity` in `cefapp.json`.
3. The first "Apple Development" identity in your keychain, else the first
   "Developer ID Application" identity.
4. Ad hoc, when there is none.

The plugin reads the team identifier from the certificate's
organizational unit (the parenthesized identifier in an Apple Development
certificate's name is the person's, not the team's). Finding the identity
and reading the certificate do not touch its private key; `codesign` does,
and macOS may ask once for access to it.

In Xcode, the identity is the build's, `EXPANDED_CODE_SIGN_IDENTITY`, and
the team `DEVELOPMENT_TEAM`: the phase signs the parts inside the app with
what Xcode then signs the app with ([Signing in Xcode](/ship/tracks#signing-in-xcode)).

### Order and options

The plugin signs inside out, each item before what contains it, and never
with `--deep`:

1. Each Mach-O file in the framework's `Libraries/`. CEF ships them
   linker-signed ad hoc; re-signing them with the app's identity is what lets
   library validation load them.
2. The framework.
3. `libcefswift_helper_startup.dylib`.
4. The app's own libraries and frameworks.
5. Each resource bundle that has an `Info.plist`; a flat one is sealed as
   resources by the app's signature.
6. Each helper app, with its entitlements.
7. The app, with its entitlements and the embedded profile.

Executables (the app and helpers) get `--options runtime` when the hardened
runtime is on; libraries and the framework take no options or entitlements,
since they run with those of the process that loads them. `--timestamp`
adds a secure timestamp (it needs a network connection); otherwise the
plugin passes `--timestamp=none`, so signing works offline.

| Identity | Hardened runtime | Timestamp | `get-task-allow` |
|---|---|---|---|
| Ad hoc | Off (with `--hardened-runtime`, `disable-library-validation` is added) | Off | No |
| Apple Development | On | Off | Added, so the app can be debugged |
| Developer ID Application | On | On | Refused: notarization rejects it |

### Entitlements

Each part's entitlements are built from:

| Part | Built in | Added |
|---|---|---|
| App | None | Each capability's; the `entitlements` file's; with a profile, `com.apple.application-identifier` and `com.apple.developer.team-identifier` from it, as Xcode adds them |
| Renderer, GPU helpers | `com.apple.security.cs.allow-jit` | `helperEntitlements` |
| Base helper | None | `device.camera` and `device.audio-input` from those capabilities (Chromium can run its video capture and audio services there); `cs.disable-library-validation` from `protectedMedia`, for Widevine; `helperEntitlements` |
| Alerts, Plugin helpers | None | `helperEntitlements` |

The built-in ones follow CEF's
[code signing guide](https://chromiumembedded.github.io/cef/code_signing)
and Chromium's `chrome/app/helper-renderer-entitlements.plist` and
`helper-gpu-entitlements.plist`: V8 and the GPU process's shader compilers
generate code at run time, which the hardened runtime allows only with
`allow-jit`.

Library validation, part of the hardened runtime, loads a library only when
it carries the process's team identifier (or Apple's). With a team
signature that holds for every library, since the plugin signs each one,
the startup library and CEF's own included, with the app's identity. No part
needs `com.apple.security.cs.disable-library-validation` except for
Google's Widevine CDM. Chromium downloads the CDM at run time, Google's team
signs it, and it loads into the base helper (`<App> Helper.app`, in the
utility process `media.mojom.CdmServiceBroker`), where a team signature's
library validation refuses it. The `protectedMedia` capability adds
`disable-library-validation` to that helper only. Chrome needs no such
entitlement because Google signs both Chrome and the CDM. A signature without
a team (ad hoc or self-signed) matches nothing, and the framework fails to
load with "mapping process and mapped file (non-platform) have different
Team IDs". With the hardened runtime on such a signature, the plugin adds
`disable-library-validation` to the app and every helper and says so.

Strings in entitlements files may use `$(TeamIdentifierPrefix)` and
`$(AppIdentifierPrefix)` (`<team ID>.`), `$(TeamIdentifier)` and
`$(CFBundleIdentifier)`.

Restricted entitlements, which a provisioning profile has to authorize
(`keychain-access-groups`, `com.apple.application-identifier` and every
`com.apple.developer.…` key), need an Apple team signature and a profile.
macOS kills an app that claims one its profile does not authorize. So the
plugin:

- refuses to sign an `entitlements` file with a restricted entitlement
  when the bundle is signed ad hoc or has no profile, or when the profile
  does not authorize it, and says which;
- leaves out a capability's restricted entitlements in those cases, with a
  warning naming what is lost, so the same `cefapp.json` builds ad hoc and
  signed;
- refuses restricted entitlements for helpers, which have no profile of
  their own.

### Provisioning profile

`provisioningProfile` is decoded with `security cms -D -i` and checked
before anything is built. Errors stop the bundle:

- the profile is not for macOS, or has expired;
- its team is not the identity's;
- its App ID does not match `<team ID>.<bundle ID>` (wildcard App IDs
  match by prefix);
- it is a development profile with a Developer ID identity, or the other
  way round;
- it does not list the signing certificate;
- it does not authorize an entitlement the app claims.

Download profiles from Certificates, Identifiers & Profiles on the Apple
Developer website: a "Developer ID" profile for distribution, a "macOS App
Development" profile for development builds. Both need an App ID for the
bundle identifier with the capabilities enabled.

## Signing and capabilities

`CefRuntime.shared.capabilities` (also `CefAppCapabilities.current`)
describes what the running app's signature, entitlements and Info.plist let
Chromium do, so the app can adapt its UI:

```swift
let capabilities = CefRuntime.shared.capabilities
if !capabilities.webAuthnAuthenticators.contains(.iCloudKeychain) {
    // Offer the app's own passkeys (CefPasskeyController) instead.
}
```

| Property | Value |
|---|---|
| `signature` | `.unsigned`, `.adHoc`, `.development`, `.developerID`, `.appStore` or `.other` (a certificate without an Apple team). `.appStore` is diagnostic only, like `isAppSandboxed`. |
| `teamIdentifier` | The team of an Apple certificate, else nil. |
| `isHardenedRuntime` | From the signature's flags. |
| `isAppSandboxed` | From the entitlements. Diagnostic only: the App Sandbox is not supported with official CEF builds and bundling refuses it, so a bundled app never reports `true` ([App Sandbox](/ship/sandbox#app-sandbox)). |
| `entitlements`, `keychainAccessGroups` | The entitlements the signature grants. |
| `usageDescriptions` | The `NS…UsageDescription` keys in the Info.plist. |
| `webAuthnAuthenticators` | `.securityKey`, `.hybrid`, `.iCloudKeychain`: Chromium's native WebAuthn authenticators the app's signature and configuration make it eligible for. Not proof that one is attached or that the user will authorize it. |
| `canLoadWidevine` | Whether the base helper can load Google's Widevine CDM: false for a team-signed hardened helper without `disable-library-validation` (the `protectedMedia` capability). |
| `resolvedSafeStorage(_:)` | The safe-storage policy Chromium gets for a configured one. |

At start-up CefSwift logs one line (subsystem `CefSwift`) naming what the
signature leaves out, such as "safe storage uses a mock keychain".
`swift package cef doctor <App.app>` reports the same for a bundle on disk.

## Keychain access

Chromium encrypts cookies and saved passwords with a key it keeps in an
item of the user's keychain. The first time an app reads that item, macOS
asks the user to allow it. Choosing Always Allow records the
app's code signature, so the question does not come back while the signature
stays the same. An ad hoc signature changes with every build, so ad hoc
signed builds are asked again after each rebuild.

`configuration.safeStorage` chooses the behavior, and
`configuration.keychainItem` the item:

| Policy | Behavior |
|---|---|
| `.automatic` (default) | `.keychain` when the app is signed with a team identity, such as an Apple Development or Developer ID certificate; `.mockKeychain` when it is unsigned or ad hoc signed. |
| `.keychain` | Always use the keychain, as Chrome does. |
| `.mockKeychain` | Use a fixed key and never touch the keychain (`--use-mock-keychain`). Nothing is protected at rest; use it for development, demos and tests. |

| `keychainItem` | Item |
|---|---|
| `.application` (default) | The app's own: service "`<bundle identifier>` Safe Storage", account "`<bundle identifier>`". Other apps built on Chromium cannot read it. |
| `.chromium` | Chromium's "Chromium Safe Storage", shared by every app built on stock Chromium or CEF that names no other. |
| `.named(service:account:)` | An item of your choice, for instance one several of your apps share. |

The item holds the key, so a different item means a different key:
cookies and passwords a profile saved under the old item cannot be read
under the new one, and Chromium drops them. Choose the item before you
ship. `keychainItem` applies only while Chromium uses the keychain; the mock
keychain of ad hoc builds has no item.

`cef bundle` signs with your Apple Development or Developer ID identity
when the keychain has one; [bundling](/ship/notarization#distribution) lists what
each kind of signature allows.

## Prompts macOS shows

Nothing CefSwift starts asks macOS for a permission unless your app or a
page asks for the capability first. What each could ask for, and when:

| Prompt | When it can appear | Guard |
|---|---|---|
| Notifications (app and Alerts helper) | At launch, only with `services.systemNotifications = .automatic`. | Off by default. |
| Keychain ("… Safe Storage") | At launch, when Chromium reads its encryption key, with `safeStorage` resolving to `.keychain` (team-signed builds). | Ad hoc and unsigned builds use the mock keychain; see [Keychain access](/ship/signing#keychain-access). |
| Location | When a page calls the Geolocation API and the permission is granted. Chromium registers a location client at launch, which asks nothing. | The page's permission request and your decision. |
| Camera, microphone | When a page calls `getUserMedia` and the permission is granted. Chromium only reads the current authorization at launch, which never prompts. | The same. |
| Local Network | When Cast discovery starts (the Cast dialog, a page's Presentation API) in a configuration with `MediaRouter` on, such as `.chrome`. Chromium browses no service at launch. | `.embedded` disables `MediaRouter`. |
| Bluetooth | When a page calls Web Bluetooth. | The page's request and your decision. |
| Input Monitoring | Never: Chromium only checks the current authorization (`CGPreflightListenEventAccess`) in `.chrome`. | — |
| Passkeys (Touch ID, iCloud Keychain) | When a page asks for a passkey. | The page's request; see [Passkeys](/browser/passkeys#passkeys). |

SelfTest's `systemPrompts` group checks the notification and TCC rows for
both presets at every run, from inside the app and from the unified log.

## System notifications

`services.systemNotifications` decides where pages' notifications appear.
It is the one service option that does not default to Chromium's choice:

| Value | Notifications | Asks macOS |
|---|---|---|
| `.disabled` (default, every preset) | In popups Chromium draws in the app. | Never. Neither the app nor `<App> Helper (Alerts)` touches the notification center, and the Alerts helper does not start. |
| `.automatic` | In macOS's Notification Center, as banners of the app and alerts of its Alerts helper. | At every launch, as Chromium sets up each profile, whether or not a page notifies: macOS shows two permission banners at the first launch, one for the app and one for the Alerts helper. |

A page still has to ask for the notifications permission, and you or the
user have to grant it (`CefPageDelegate`'s permission decision, or
`profile.siteSettings.set(.allow, for: .notifications, origin:)`), in either
case. Turn system notifications on only in an app whose users expect
notifications in Notification Center, and expect the permission banners at
its first launch:

```swift
var configuration = CefRuntime.Configuration.chrome
configuration.services.systemNotifications = .automatic
```

`.disabled` disables Chromium's `SystemNotifications` feature; an app that
lists it in `enabledFeatures` turns system notifications on as well.
