Author: Caden Randolph

Verifying macros on an Excel document

How to Inspect a Macro-Enabled Excel File Before You Trust It

A practical guide for anyone who’s ever hovered over “Enable Content” and wondered if they should.


You receive an .xlsm file from a vendor, a colleague, or a download. It asks you to enable macros. Before you click that button, there’s a better question to ask: what does this macro actually do?

This guide walks through a repeatable process for inspecting macro-enabled Office files — without running them first.


Why This Matters

Macros are Visual Basic for Applications (VBA) programs embedded in Office documents. They can automate legitimate tasks like building Gantt charts or generating reports, but they can also execute system commands, download files from the internet, or exfiltrate data. The problem is that Office gives you no way to tell the difference before you enable them.

Making things worse: files can be password-protected, which locks the VBA editor inside Office and prevents you from reading the code through normal means. This is sometimes legitimate (vendors protecting IP), sometimes suspicious.

The good news is that password protection only blocks the Office UI — it doesn’t protect the underlying binary.


What You’ll Need

olevba is the primary tool. It’s part of the oletools Python package, developed by Philippe Lagadec, and it reads VBA source code directly from the file binary, bypassing password protection entirely.

Windows

Open a command prompt and run pip install oletools. That’s it.

Mac — Read This First

Mac requires a couple of extra steps. macOS ships with Python 2 (or no Python at all on newer versions), and running pip install oletools will either fail or try to install into a system location Apple doesn’t want you touching.

Step 1: Install Python 3 via Homebrew

If you don’t have Homebrew installed yet, open Terminal and run this command:

/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”

Then install Python 3 with brew install python3 and verify with python3 –version.

Step 2: Create a virtual environment

macOS will block pip install at the system level with an externally-managed-environment error. The fix is to install into a virtual environment instead — an isolated folder that doesn’t touch system Python at all.

Create the environment once with python3 -m venv oletools-env, then activate it with source oletools-env/bin/activate. Your prompt will change to show (oletools-env). Now run pip install oletools.

When you’re done, run deactivate to exit the environment. Next time you want to use olevba, just run source oletools-env/bin/activate first.


Step 1: Run the Basic Scan

Run olevba your_file.xlsm replacing the filename with your actual file. This extracts all VBA modules and produces a summary table at the bottom flagging suspicious keywords. It looks something like this:

Type: AutoExec — Keyword: Workbook_Open — Runs when the Excel Workbook is opened

Type: Suspicious — Keyword: Shell — May run an executable file or system command

Type: Suspicious — Keyword: CreateObject — May create an OLE object

Type: IOC — Keyword: https://example.com — URL

Don’t panic at this table. Every flag needs to be read in context — a Shell call that opens a saved PDF is very different from one that executes a downloaded payload.


Step 2: Read the Actual Code

The summary table tells you what keywords exist. The code tells you what they do. Scroll up from the summary and read through each module.

Here’s what to look for:

AutoExec Triggers

These run automatically without any user interaction. The function is called Workbook_Open and it executes the moment macros are enabled. Pay close attention to Workbook_Open, Auto_Open, and Document_Open — these are the entry points. Start reading here.

Shell and Command Execution

This is the most dangerous class of behavior. A legitimate use opens a known application like Windows Explorer with a file path. A suspicious one passes an encoded string to PowerShell — something like Shell “powershell -enc ” & encodedCommand. Encoded PowerShell is a significant red flag. It means the author is deliberately hiding what’s being executed.

Network Activity

Code that creates a WinHttpRequest object and calls a URL isn’t automatically malicious — license validation, version checks, and telemetry are common. The question is: what URL, and what data is being sent? Check whether any sensitive data like usernames, file contents, or environment variables is included in the request.

Obfuscation

Legitimate code rarely needs to hide itself. Watch for long chains of Chr() calls building strings character by character, Base64-encoded strings being decoded at runtime, and variables with meaningless names holding fragments of a URL or command. For example, a string of Chr() calls decoding to “powershell” is a serious warning sign. Run olevba –decode to attempt automatic deobfuscation.


Step 3: Understand VBA Stomping

olevba sometimes flags VBA Stomping — a condition where the stored source code and the compiled P-code differ. This matters because Office can execute either version, and they may not do the same thing. When detected, the summary will flag it as suspicious with the message “VBA source code and P-code are different.”

This has two common explanations:

  1. Vendor IP protection — commercial software vendors sometimes strip or obfuscate the source while keeping the compiled P-code intact. The macro works, but you can’t easily read it.
  2. Deliberate evasion — malware authors use this to show scanners one thing while actually executing another.

Context matters here. A stomped file from a known vendor with a plausible business reason is very different from a stomped file that arrived via email from an unknown sender.


Step 4: Check for the Real Red Flags

After reading the code, here are the things that should genuinely concern you, regardless of context:

FindingWhy It’s Concerning
Encoded PowerShell (-enc, -encodedCommand)Actively hiding executed commands
Downloads to %TEMP% then executesClassic dropper behavior
Reads Office credentials or saved passwordsData theft
Sends data to an unexpected external URLExfiltration
CreateObject(“Scripting.FileSystemObject”) writing filesPersistent malware installation
Multiple layers of deobfuscationEvasion of security tools

And here are things that look suspicious but usually aren’t:

FindingLikely Explanation
Shell opening a known applicationOpening exported files, launching browser
CreateObject(“WinHttp…”)License validation, update checks
Environ(“computername”)License tying, telemetry
Mac-specific popen / libc.dylib callsCross-platform compatibility code
VBA Stomping on a commercial productVendor IP protection

Step 5: For High-Stakes Files, Go Further

If the file is from an untrusted source or contains something you still can’t explain after reading the code, use these additional steps:

Run in an isolated environment. A virtual machine with no network access and no access to your real files is the safest way to observe runtime behavior. Tools like Any.run or Cuckoo Sandbox can automate this.

Rename and extract. .xlsm files are ZIP archives. Change the extension to .zip, extract, and look at xl/vbaProject.bin alongside the XML files in xl/. You can sometimes find hardcoded strings, URLs, or file paths that aren’t obvious in the VBA source.

Search the hash. Run the file through VirusTotal. If it’s a known malicious file or a known legitimate commercial product, you’ll often find it there.


A Complete Example Workflow

Windows: Run pip install oletools, then olevba suspicious_file.xlsm to scan. Add –decode to the command if you see encoded strings. Pipe to a text file with olevba suspicious_file.xlsm > analysis.txt to save the output for sharing.

Mac: Activate your environment first with source oletools-env/bin/activate, then run the same olevba commands above. The same commands work on .docm and .pptm files too.


The Decision Framework

After completing the analysis, the decision comes down to three questions:

  1. Can I explain every suspicious flag? If yes, and the explanations are plausible given the source of the file, enable with confidence.
  2. Is there anything I can’t explain? If yes, don’t enable until you can. Reach out to the vendor, check community forums, or run it in isolation first.
  3. Does the source match the behavior? A license validation call to shop.knownvendor.com from a file you downloaded from that vendor’s website is fine. The same call in a file that arrived unsolicited from an unknown email address is not.

Summary

Enabling macros without inspection is a habit worth breaking. The tools to do this properly are free, install in seconds, and bypass password protection that would otherwise stop you. A ten-minute review is usually enough to either confirm a file is safe or surface something that warrants a closer look.

The goal isn’t to become a malware analyst — it’s to develop enough familiarity with what legitimate macro code looks like that you can recognize when something doesn’t fit.


Tools referenced: oletools by Philippe Lagadec — free, open source, actively maintained.


Categories: Security, Cybersecurity, Productivity, Microsoft Office, How-To Guides

Tags: olevba, oletools, VBA macros, Excel security, macro analysis, xlsm, malware analysis, phishing, office documents, VBA stomping, Python, Homebrew, virtual environment, venv, macOS setup, Windows security, file inspection, enable macros, password protected files, WinHTTP, CreateObject, AutoExec, obfuscation, base64, PowerShell, VirusTotal, sandboxing, threat analysis, IT security, enterprise security

Issuing CBA Certificates for New Users in Microsoft Entra ID

You’ve already set up Certificate-Based Authentication (CBA) in your tenant — your Root CA is uploaded, the authentication method is enabled, and username bindings are configured. Now you need to issue certificates for additional users. This guide covers generating, packaging, and deploying user certificates on both macOS and Windows, plus automating deployment for Windows Entra enrollment.


Prerequisites

  • CBA is enabled in your Entra ID tenant (see the companion article: Setting Up CBA for a New Tenant)
  • Your Root CA files (rootCA.key and rootCA.crt) are accessible
  • OpenSSL is installed on your machine
  • The new user’s account already exists in Entra ID and you know their UPN (e.g., jane@yourdomain.com)

Step 1: Generate the User’s Private Key and CSR

Every user gets their own key pair and certificate. The critical requirement is including the user’s UPN in the Subject Alternative Name using the Microsoft UPN OID.

On macOS / Linux

bash

openssl genrsa -out jane-cba.key 2048

openssl req -new -key jane-cba.key \
  -out jane-cba.csr \
  -subj "/CN=jane@yourdomain.com" \
  -addext "subjectAltName=otherName:1.3.6.1.4.1.311.20.2.3;UTF8:jane@yourdomain.com"

On Windows (PowerShell or Git Bash)

bash

openssl genrsa -out jane-cba.key 2048

openssl req -new -key jane-cba.key -out jane-cba.csr -subj "/CN=jane@yourdomain.com" -addext "subjectAltName=otherName:1.3.6.1.4.1.311.20.2.3;UTF8:jane@yourdomain.com"

Replace jane@yourdomain.com with the user’s actual UPN in Entra ID. The UPN must match exactly — including case — for the username binding to work.


Step 2: Sign the Certificate with Your Root CA

bash

openssl x509 -req -in jane-cba.csr \
  -CA rootCA.crt -CAkey rootCA.key -CAcreateserial \
  -out jane-cba.crt -days 365 -sha256 \
  -copy_extensions copyall

The -copy_extensions copyall flag is essential — it copies the SAN from the CSR into the signed certificate. Without it, the SAN is silently dropped and CBA authentication will fail.


Step 3: Bundle into a .pfx File

On macOS

If you’re running OpenSSL 3.x (most modern Macs), use the -legacy flag so macOS Keychain can read the file:

bash

openssl pkcs12 -export -out jane-cba.pfx \
  -inkey jane-cba.key \
  -in jane-cba.crt \
  -certfile rootCA.crt \
  -legacy

On Windows

bash

openssl pkcs12 -export -out jane-cba.pfx -inkey jane-cba.key -in jane-cba.crt -certfile rootCA.crt

You’ll be prompted for an export password. For manual installs, pick something secure. For automated deployments, you’ll embed this password in your deployment script, so be aware of that tradeoff.

Tip: When prompted interactively, avoid special characters like @, !, # in the password — shells can interpret them unexpectedly. Stick to alphanumeric passwords to avoid “MAC verification failed” headaches.


Step 4: Import the Certificate on the User’s Machine

On macOS

Import both the user certificate and the root CA:

bash

security import jane-cba.pfx -k ~/Library/Keychains/login.keychain-db -P "YourPassword"
security import rootCA.cer -k ~/Library/Keychains/login.keychain-db

If the root CA was already imported on this machine (e.g., for another user), the second command will note it’s a duplicate, which is harmless.

Troubleshooting: “MAC verification failed during PKCS12 import”

This means the .pfx was created with OpenSSL 3.x’s newer encryption format. Recreate it with the -legacy flag (see Step 3).

On Windows — Manual Install

GUI method:

  1. Double-click the .pfx file
  2. Select Current User as the store location
  3. Enter the export password
  4. Accept the defaults and complete the wizard

Command line (run as Administrator):

powershell

certutil -addstore Root rootCA.cer
certutil -importpfx jane-cba.pfx

You’ll be prompted for the .pfx password.

On Windows — Automated via autounattend.xml

If you’re deploying Windows via USB with an unattended install, you can import the certificate automatically during setup.

USB folder structure:

ESD-USB:\
├── autounattend.xml
└── Certs\
    ├── rootCA.cer
    └── jane-cba.pfx

Add this to your autounattend.xml inside the appropriate settings pass (e.g., oobeSystem or specialize):

xml

<RunSynchronousCommand wcm:action="add">
    <Order>1</Order>
    <Path>powershell -ExecutionPolicy Bypass -Command "$d=(Get-Volume -FileSystemLabel 'ESD-USB').DriveLetter; certutil -addstore Root ${d}:\Certs\rootCA.cer; certutil -importpfx -p 'YourPassword' ${d}:\Certs\jane-cba.pfx"</Path>
    <Description>Import CBA Certificates</Description>
</RunSynchronousCommand>

This command dynamically finds the USB drive by its volume label (ESD-USB), so it works regardless of which drive letter Windows assigns.

Security note: The .pfx password is stored in plaintext in the XML. Treat the USB as a sensitive asset, and consider wiping or rotating the certificate after deployment.


Step 5: Test the Login

  1. Fully quit the browser (Cmd+Q on macOS, or close all windows on Windows)
  2. Open the browser and go to https://login.microsoftonline.com
  3. Enter the user’s email address
  4. Choose “Use a certificate or smart card”
  5. Select the certificate from the picker dialog
  6. On macOS, enter the Mac login password when the Keychain prompt appears — click Always Allow to avoid being asked again

Step 6: Set CBA as the Default Sign-In Method

After a successful first login with the certificate, the user can set CBA as their default authentication method:

  1. Go to https://mysignins.microsoft.com/security-info
  2. Click “Change default sign-in method”
  3. Select Certificate-based authentication
  4. Save

Note: You cannot change another user’s default sign-in method from the Entra admin center. Each user must set their own default from the My Security Info portal.


Scripting Bulk User Certificate Generation

If you need to issue certificates for many users at once, here’s a bash script that automates the process:

bash

#!/bin/bash

# List of user UPNs
USERS=(
  "jane@yourdomain.com"
  "john@yourdomain.com"
  "alex@yourdomain.com"
)

PFX_PASSWORD="TempDeploy2024"

for UPN in "${USERS[@]}"; do
  USERNAME=$(echo "$UPN" | cut -d'@' -f1)
  echo "Generating certificate for $UPN..."

  # Generate key
  openssl genrsa -out "${USERNAME}-cba.key" 2048 2>/dev/null

  # Generate CSR with SAN
  openssl req -new \
    -key "${USERNAME}-cba.key" \
    -out "${USERNAME}-cba.csr" \
    -subj "/CN=${UPN}" \
    -addext "subjectAltName=otherName:1.3.6.1.4.1.311.20.2.3;UTF8:${UPN}" \
    2>/dev/null

  # Sign with Root CA
  openssl x509 -req \
    -in "${USERNAME}-cba.csr" \
    -CA rootCA.crt -CAkey rootCA.key -CAcreateserial \
    -out "${USERNAME}-cba.crt" -days 365 -sha256 \
    -copy_extensions copyall \
    2>/dev/null

  # Bundle PFX (with -legacy for macOS compatibility)
  openssl pkcs12 -export \
    -out "${USERNAME}-cba.pfx" \
    -inkey "${USERNAME}-cba.key" \
    -in "${USERNAME}-cba.crt" \
    -certfile rootCA.crt \
    -legacy \
    -password "pass:${PFX_PASSWORD}" \
    2>/dev/null

  echo "  Created ${USERNAME}-cba.pfx"

  # Clean up intermediate files
  rm -f "${USERNAME}-cba.key" "${USERNAME}-cba.csr" "${USERNAME}-cba.crt"
done

echo "Done. All .pfx files ready for deployment."

Windows equivalent (PowerShell)

powershell

$users = @(
    "jane@yourdomain.com",
    "john@yourdomain.com",
    "alex@yourdomain.com"
)

$pfxPassword = "TempDeploy2024"

foreach ($upn in $users) {
    $username = $upn.Split("@")[0]
    Write-Host "Generating certificate for $upn..."

    openssl genrsa -out "$username-cba.key" 2048 2>$null

    openssl req -new `
        -key "$username-cba.key" `
        -out "$username-cba.csr" `
        -subj "/CN=$upn" `
        -addext "subjectAltName=otherName:1.3.6.1.4.1.311.20.2.3;UTF8:$upn"

    openssl x509 -req `
        -in "$username-cba.csr" `
        -CA rootCA.crt -CAkey rootCA.key -CAcreateserial `
        -out "$username-cba.crt" -days 365 -sha256 `
        -copy_extensions copyall

    openssl pkcs12 -export `
        -out "$username-cba.pfx" `
        -inkey "$username-cba.key" `
        -in "$username-cba.crt" `
        -certfile rootCA.crt `
        -password "pass:$pfxPassword"

    Write-Host "  Created $username-cba.pfx"

    Remove-Item "$username-cba.key", "$username-cba.csr", "$username-cba.crt" -ErrorAction SilentlyContinue
}

Write-Host "Done. All .pfx files ready for deployment."

Deploying Certificates via Intune (SCEP/PKCS)

For larger organizations, manually distributing .pfx files doesn’t scale. Microsoft Intune supports automated certificate deployment through SCEP and PKCS certificate profiles. The high-level process is:

  1. Set up a certificate connector — Install the Microsoft Intune Certificate Connector on a Windows Server that has access to your CA
  2. Create a Trusted Certificate profile — Deploy your root CA certificate to devices
  3. Create a PKCS or SCEP certificate profile — Configure Intune to automatically issue and deploy user certificates to enrolled devices

This is a more complex setup but eliminates the need to manually handle .pfx files for each user. Refer to Microsoft’s documentation on Intune certificate connectors for detailed steps.


Revoking a User’s Certificate

If a user leaves the organization or their certificate is compromised, you have several options:

  • Disable the user account in Entra ID — this prevents sign-in regardless of the certificate
  • Delete the certificate from the user’s machine
  • Set up CRL validation in the CBA configuration and publish a Certificate Revocation List through your CA

For immediate revocation without CRL infrastructure, disabling the user account is the fastest approach.


Quick Reference: Commands at a Glance

TaskCommand
Generate keyopenssl genrsa -out user.key 2048
Create CSR with SANopenssl req -new -key user.key -out user.csr -subj "/CN=user@domain.com" -addext "subjectAltName=otherName:1.3.6.1.4.1.311.20.2.3;UTF8:user@domain.com"
Sign certificateopenssl x509 -req -in user.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out user.crt -days 365 -sha256 -copy_extensions copyall
Create PFX (macOS)openssl pkcs12 -export -out user.pfx -inkey user.key -in user.crt -certfile rootCA.crt -legacy
Create PFX (Windows)openssl pkcs12 -export -out user.pfx -inkey user.key -in user.crt -certfile rootCA.crt
Import on macOSsecurity import user.pfx -k ~/Library/Keychains/login.keychain-db -P "password"
Import on Windowscertutil -importpfx user.pfx

Setting Up Certificate-Based Authentication (CBA) in Microsoft Entra ID — From Scratch

Certificate-Based Authentication (CBA) lets users sign in to Microsoft 365 and Azure services using an X.509 certificate instead of a password. It’s phishing-resistant, passwordless, and pairs beautifully with smart cards and USB security keys. This guide walks you through the entire process of enabling CBA in a brand-new Entra ID tenant, from creating your own Certificate Authority to a successful first login.


Prerequisites

  • A Microsoft Entra ID (Azure AD) tenant with at least a P1 license
  • Global Administrator or Authentication Policy Administrator role
  • OpenSSL installed on your machine (comes pre-installed on macOS and most Linux distros; on Windows, install via Git for Windows or OpenSSL for Windows)
  • A user account to test with

Step 1: Create Your Root Certificate Authority

You need a Certificate Authority (CA) to sign user certificates. For production environments you’d use Active Directory Certificate Services or a third-party CA, but a self-signed root CA works perfectly for smaller organizations.

On macOS / Linux

Open Terminal and run:

openssl genrsa -out rootCA.key 4096
openssl req -x509 -new -key rootCA.key -sha256 -days 1825 -out rootCA.crt -subj "/CN=YourOrg Root CA"

On Windows

Open PowerShell or Git Bash and run:

openssl genrsa -out rootCA.key 4096
openssl req -x509 -new -key rootCA.key -sha256 -days 1825 -out rootCA.crt -subj "/CN=YourOrg Root CA"

This creates two files:

  • rootCA.key — Your CA’s private key. Guard this carefully. Anyone with this file can issue trusted certificates for your tenant.
  • rootCA.crt — Your CA’s public certificate. This gets uploaded to Entra ID.

Step 2: Convert the Root CA to .cer Format

Entra ID expects a .cer file for upload. Convert your root certificate:

openssl x509 -in rootCA.crt -out rootCA.cer -outform DER

If you run into issues with DER format during upload, try PEM instead:

openssl x509 -in rootCA.crt -out rootCA.cer -outform PEM

Step 3: Upload the Root CA to Entra ID

  1. Sign in to the Microsoft Entra admin center
  2. Navigate to Security → Certificate authorities
  3. Click Upload
  4. Upload your rootCA.cer file
  5. Toggle “Is root CA” to Yes
  6. Click Save

You should now see your CA listed with its thumbprint and expiration date.


Step 4: Enable Certificate-Based Authentication

  1. In the Entra admin center, go to Security → Authentication methods → Policies
  2. Find Certificate-based authentication and click on it
  3. On the Enable and Target tab:
    • Toggle the method to Enabled
    • Under Target, set it to All users or select a specific group
  4. Click Save

Step 5: Configure Username Binding

This is the step that trips most people up. You need to tell Entra ID how to match a certificate to a user account.

  1. Still in the CBA configuration, click the Configure tab
  2. Scroll down to Username binding
  3. You should see default rules for PrincipalName, RFC822Name, and SKI

The PrincipalName binding maps the certificate’s Subject Alternative Name (SAN) UPN field to the user’s userPrincipalName in Entra. This is the binding we’ll use.

Important: The PrincipalName binding looks for the Microsoft UPN OID (1.3.6.1.4.1.311.20.2.3) in the certificate’s SAN extension — not the Subject CN field. Your certificates must include this SAN, or authentication will fail with “No value in the certificate, as requested by tenant policy, is able to validate the user claim.”

Optional: CRL Validation

On the Configure tab you’ll also see Certificate revocation list (CRL) validation. For initial setup, leave “Require CRL validation” unchecked. You can enable it later once you have a CRL distribution point configured for your CA.


Step 6: Generate a User Certificate

Now create a certificate for your first user. The critical piece is including the UPN in the Subject Alternative Name using the Microsoft UPN OID.

On macOS / Linux

openssl genrsa -out user-cba.key 2048

openssl req -new -key user-cba.key \
  -out user-cba.csr \
  -subj "/CN=user@yourdomain.com" \
  -addext "subjectAltName=otherName:1.3.6.1.4.1.311.20.2.3;UTF8:user@yourdomain.com"

openssl x509 -req -in user-cba.csr \
  -CA rootCA.crt -CAkey rootCA.key -CAcreateserial \
  -out user-cba.crt -days 365 -sha256 \
  -copy_extensions copyall

On Windows

openssl genrsa -out user-cba.key 2048

openssl req -new -key user-cba.key -out user-cba.csr -subj "/CN=user@yourdomain.com" -addext "subjectAltName=otherName:1.3.6.1.4.1.311.20.2.3;UTF8:user@yourdomain.com"

openssl x509 -req -in user-cba.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out user-cba.crt -days 365 -sha256 -copy_extensions copyall

Replace user@yourdomain.com with the user’s actual UPN in Entra ID.


Step 7: Bundle into a .pfx File

Combine the certificate and private key into a PKCS#12 (.pfx) file. This is the portable format you’ll import onto the user’s machine.

On macOS

macOS Keychain requires the legacy PKCS#12 format. If you’re on OpenSSL 3.x (check with openssl version), add the -legacy flag:

openssl pkcs12 -export -out user-cba.pfx \
  -inkey user-cba.key \
  -in user-cba.crt \
  -certfile rootCA.crt \
  -legacy

On Windows

openssl pkcs12 -export -out user-cba.pfx -inkey user-cba.key -in user-cba.crt -certfile rootCA.crt

You’ll be prompted to set an export password. Remember it — you’ll need it during import.


Step 8: Import the Certificate

On macOS

security import user-cba.pfx -k ~/Library/Keychains/login.keychain-db -P "YourPassword"
security import rootCA.cer -k ~/Library/Keychains/login.keychain-db

If the security import command fails with “MAC verification failed during PKCS12 import,” you need to recreate the .pfx with the -legacy flag (see Step 7).

On Windows

Option A — GUI:

  1. Double-click the .pfx file
  2. The Certificate Import Wizard opens
  3. Choose Current User and click Next
  4. Enter the export password
  5. Leave defaults and click through to finish

Option B — Command line (run as Administrator):

certutil -addstore Root rootCA.cer
certutil -importpfx user-cba.pfx

Step 9: Test the Login

  1. Fully quit your browser (Cmd+Q on Mac, or close all windows on Windows)
  2. Reopen the browser and navigate to https://login.microsoftonline.com
  3. Enter the user’s email address
  4. When prompted, choose “Use a certificate or smart card”
  5. Your OS will present a certificate picker — select the correct certificate
  6. On macOS, you’ll be prompted for your Mac login password (Keychain password) — enter it and click Always Allow

If everything is configured correctly, you’ll be signed in.


Troubleshooting

“No certificate detected”

The certificate isn’t installed in your OS certificate store, or your browser needs to be restarted. Make sure both the user .pfx and root CA .cer are imported.

“We couldn’t sign you in with a certificate”

The certificate was found and sent, but Entra rejected it. Check the Sign-in logs in Entra admin center for the specific error code.

Error 1001009: “No value in the certificate… is able to validate the user claim”

Your certificate doesn’t have the UPN in the SAN field. Regenerate the certificate with the -addext "subjectAltName=otherName:1.3.6.1.4.1.311.20.2.3;UTF8:user@domain.com" flag and use -copy_extensions copyall when signing.

“MAC verification failed during PKCS12 import” (macOS)

OpenSSL 3.x uses newer encryption that macOS Keychain doesn’t support. Recreate the .pfx with the -legacy flag.


Security Best Practices

  • Protect your Root CA key. Store rootCA.key offline or in a hardware security module. Anyone with this key can issue certificates trusted by your tenant.
  • Set reasonable certificate lifetimes. 365 days for user certificates is a good balance between security and convenience.
  • Enable CRL validation once you have a revocation infrastructure in place, so you can revoke compromised certificates.
  • Consider Multi-Factor strength. In the CBA configuration, you can set the authentication strength to Multi-factor if CBA should satisfy your MFA requirements on its own.

Automating Certificate Deployment via USB (Windows)

If you’re deploying certificates as part of a Windows unattended install, you can automate the import. Place rootCA.cer and user-cba.pfx in a Certs folder on your USB drive, then add the following to your autounattend.xml:

<RunSynchronousCommand wcm:action="add">
    <Order>1</Order>
    <Path>powershell -ExecutionPolicy Bypass -Command "$d=(Get-Volume -FileSystemLabel 'ESD-USB').DriveLetter; certutil -addstore Root ${d}:\Certs\rootCA.cer; certutil -importpfx -p 'YourPassword' ${d}:\Certs\user-cba.pfx"</Path>
    <Description>Import CBA Certificates</Description>
</RunSynchronousCommand>

This automatically finds the USB by volume label and imports both certificates during Windows setup.


What’s Next?

Now that your tenant is set up for CBA, adding new users is straightforward — you just generate a new certificate for each user using the same Root CA. See the companion article: Issuing CBA Certificates for New Users.

© 2026 Ultrex Staff

Theme by Anders NorenUp ↑