Skip to main content

Gmail

DuoKey
DuoKey for Google Workspace CSE — Gmail
28 November 2026
Applies to:
Gmail client-side encryptionGoogle Workspace super administratorDuoKey privileged user of the Google CSE app

How Gmail CSE works​

Gmail CSE is built on S/MIME. Each user who sends or reads encrypted email needs an S/MIME certificate and its RSA private key. With CSE, Google never stores the private key in clear: you upload it wrapped by the DuoKey KACLS. When the user signs or decrypts a message in the browser, Gmail asks DuoKey to perform the private key operation:

OperationWhenWho may call it
wrapprivatekeyOnce per key pair, before the upload to GmailPrivileged users of the app
privatekeysignSending a signed or encrypted emailThe key pair owner, with a Google authorization token
privatekeydecryptReading an encrypted emailThe key pair owner, with a Google authorization token
privilegedprivatekeydecryptPrivileged export (Takeout)Privileged users of the app

Prerequisites​

Prerequisites

  • Steps 1 to 5 of Getting Started done: DuoKey key service added and assigned to the users' OU
  • Gmail selected in the app's Google applications
  • Your administrator account listed as a privileged user of the DuoKey app
  • An S/MIME certificate (RSA) and its private key for each user, issued by a CA that Gmail trusts or whose root you upload in the Admin console
  • A Google Cloud service account with domain-wide delegation for the scope https://www.googleapis.com/auth/gmail.settings.basic

Step 1: Enable S/MIME and trust your CA​

1

Turn on S/MIME for the OU

In the Google Admin console, open Apps, Google Workspace, Gmail, User settings, select the OU and open S/MIME. Turn on Enable S/MIME encryption for sending and receiving emails.

2

Upload the root certificate

If the user certificates come from your own CA, add its root under Accept these additional root certificates for specific domains, for your domain. Save.

Google Admin console Gmail S/MIME settings with S/MIME enabled and an additional root certificate accepted for the domain

Step 2: Turn on Gmail CSE​

In Data, Compliance, Client-side encryption, open Gmail and turn on client-side encryption for the OU.

Step 3: Wrap each private key with DuoKey​

1

Wrap the private key

On the app's detail page, in the Gmail S/MIME private key card, paste the user's RSA private key (PEM, PKCS#8 or PKCS#1, or base64 DER) and click Wrap private key.

2

Keep the result

DuoKey returns:

  • spki_hash: the SHA-256 hash of the public key, which DuoKey checks on every signature.
  • wrapped_private_key: the private key wrapped by the vault key. Click Download to save it.
DuoKey Cockpit Gmail S/MIME private key card with the spki_hash and the wrapped private key
Delete the clear private key

Once the key pair is uploaded to Gmail, the clear private key is no longer needed: Gmail uses only the wrapped key, and only through DuoKey. Delete every clear copy, or keep it in a protected escrow if your policy requires one.

Step 4: Upload the key pair through the Gmail API​

Use the service account with domain-wide delegation, impersonating each user (sub = the user's email address) with the scope https://www.googleapis.com/auth/gmail.settings.basic.

1

Create the key pair

Call POST https://gmail.googleapis.com/gmail/v1/users/me/settings/cse/keypairs with:

Request bodyJSON
{
"pkcs7": "<user certificate and chain, PKCS#7 PEM>",
"privateKeyMetadata": [{
  "kaclsKeyMetadata": {
    "kaclsUri": "<KACLS URL of the DuoKey app>",
    "kaclsData": "<wrapped_private_key from DuoKey>"
  }
}]
}

The response contains a keyPairId.

2

Create the CSE identity

Call POST https://gmail.googleapis.com/gmail/v1/users/me/settings/cse/identities with:

Request bodyJSON
{
"emailAddress": "<user email address>",
"primaryKeyPairId": "<keyPairId>"
}
Propagation

After the upload, the encryption option in the Gmail compose window can take up to 24 hours to appear for the user.

Step 5: Send an encrypted email​

In Gmail, compose a new message, click the lock icon and turn on Additional encryption. Gmail encrypts the message in the browser and calls DuoKey to sign it. The recipient's browser calls DuoKey (or the recipient's own key service) to decrypt it. Each operation appears in the app's Key access log.

Recipients

Encrypted email is sent with S/MIME: Gmail needs the recipient's certificate. Inside your organization the certificates come from the uploaded key pairs. For external recipients, exchange signed emails first so that each side has the other's certificate.

© 2026 DuoKey SA - Confidentialdocs.duokey.com | [email protected]