Automating Entra App Proxy Certificates with CertKit (Certificate Authentication)

Microsoft Entra ID icon

In previous posts, I described how to configure CertKit to automatically deploy renewed TLS certificates to Microsoft Entra Application Proxy applications using client secret authentication and managed identity authentication. Client secret authentication works anywhere, but the secret is a bearer credential that can be copied, pasted, logged, or leaked. A managed identity eliminates the secret, but it requires the CertKit agent to run on an Azure virtual machine or an Azure Arc-enabled server. CertKit now supports certificate authentication, which offers the best of both. The private key is created on the CertKit agent server, protected by the Trusted Platform Module (TPM), and can’t be exported, and it works on any Windows server without an Azure dependency. Version 2.0 of my New-CertKitAppProxyIdentity.ps1 PowerShell script configures it end to end in a single run, using the same least-privilege permissions as the other methods. The following sections describe how to configure it using both PowerShell and the Entra admin center.

Why Use Certificate Authentication

With certificate authentication, CertKit signs in to Microsoft Graph by signing a client assertion with the certificate’s private key, and Entra validates it against the public key uploaded to the app registration. This approach offers several advantages, including the following.

  • No shared secret. Only the public key leaves the server. CertKit stores the certificate thumbprint, which is useless without the private key.
  • Bound to the server. The private key is created in the TPM and marked non-exportable, so it can’t be copied out of the server and used elsewhere.
  • Works anywhere. No Azure subscription, Azure virtual machine, or Azure Arc agent is required. The CertKit agent can run on any Windows server, on-premises or in any cloud.
  • Aligned with Microsoft guidance. Microsoft recommends certificate credentials over client secrets for app registrations, and notes that self-signed certificates are still preferred over secrets.

The following table compares the three authentication methods CertKit supports for Entra App Proxy.

Client SecretManaged IdentityCertificate
Where the agent runsAnywhereAzure virtual machine or Azure Arc-enabled serverAny Windows server
CredentialShared secret entered in CertKitTokens issued by AzurePrivate key stored in the TPM
Can be copied and reused elsewhereYesNoNo
Azure dependencyNoneAzure subscription, plus Azure Arc outside AzureNone
RotationAt least every 12 monthsNot requiredEvery 30 to 365 days

A managed identity is a good choice when the CertKit agent already runs on an Azure virtual machine. For servers outside Azure, though, it carries a management burden. The server must be onboarded to Azure Arc, the Azure Arc agent must be kept up to date, the server needs outbound access to Azure endpoints, and an Azure subscription is required in the same tenant. Azure Arc-enabled servers also support only a system-assigned managed identity, which is shared with the Azure Arc agent and other services on the server. The Azure Arc core control plane is free, but add-on management services such as Azure Update Manager, Azure Policy guest configuration, and Microsoft Defender for Cloud are billed per server once enabled, and they’re easy to accumulate once servers are managed in Azure. Certificate authentication avoids all of this. There are tradeoffs, however. The certificate expires and must be rotated, and anyone with administrative access to the server can use the key to sign in as CertKit, even though they can’t export it. Least privilege limits the impact, just as it does with the other methods.

Requirements

Using certificate authentication with CertKit requires the following.

  • Access to the CertKit agent server. The certificate’s private key is non-exportable, so it must be created on the server running the CertKit agent, in an elevated PowerShell session. There’s no option to import an existing certificate.
  • A TPM (recommended). A physical TPM or a virtual TPM (vTPM) protects the private key in hardware. Most virtualization platforms provide a vTPM, including Hyper-V Generation 2 virtual machines, Azure virtual machines with Trusted Launch, and VMware vSphere, though it may need to be enabled. If no TPM is available, the key is stored in software instead. More on that below.
  • The Microsoft Graph PowerShell module on the agent host. The CertKit agent uses the Microsoft.Graph.Authentication module to sign in with the certificate. Since the agent runs as Local System, the module must be installed for all users. The configuration script uses the same module.
  • An administrative account. An account that can create custom roles, grant application permissions, and assign directory roles, such as Privileged Role Administrator or Global Administrator.
  • Microsoft Entra ID P1. This is already required for Application Proxy and custom roles. Assigning the role through Privileged Identity Management (PIM) requires Microsoft Entra ID P2 or Microsoft Entra ID Governance.

Required Permissions for CertKit

Certificate authentication uses an Entra app registration with the same least-privilege permissions as the client secret method, including the following.

  • Application.Read.All. A read-only Microsoft Graph application permission CertKit uses to find App Proxy applications in the tenant.
  • A custom Entra role. A custom role, named App Proxy Certificate Manager in this example, with only three permissions: read Application Proxy settings, update the Application Proxy SSL certificate, and read connector groups.

With these permissions, CertKit can’t add credentials to applications, change API permissions, or grant consent. For more details on these permissions and why built-in roles such as Application Administrator should be avoided, see the client secret post. If you’ve already created the custom role for another authentication method, you can reuse it.

Configuration Using PowerShell

You can perform the entire configuration in a single run using my New-CertKitAppProxyIdentity.ps1 PowerShell script on GitHub. Beginning with version 2.0, certificate authentication is the default. The script is also available in the PowerShell Gallery. On the CertKit agent server, open an elevated Windows PowerShell window and install the Microsoft.Graph.Authentication module for all users, along with the script, using the following commands. Be sure to use Windows PowerShell, not PowerShell 7, when installing the module. The two use separate module locations, and the CertKit agent uses Windows PowerShell.

Install-Module -Name Microsoft.Graph.Authentication -Scope AllUsers -Repository PSGallery -Force
Install-Script -Name New-CertKitAppProxyIdentity -Scope CurrentUser

Then run the script. Add -UsePim to assign the role through PIM, and -TenantId if your account has access to more than one tenant.

New-CertKitAppProxyIdentity.ps1 -UsePim

What the Script Does

A single run of the script performs the following steps.

  1. Creates a self-signed certificate in the local computer’s personal certificate store, before anything changes in Entra.
  2. Creates or reuses the custom role, the app registration, and its service principal.
  3. Grants Application.Read.All and assigns the role, either directly or through PIM.
  4. Uploads the public certificate to the app registration, named CertKit Agent – <computer name>.
  5. Removes expired certificates and client secrets from the app registration, and expired CertKit certificates from the local store.
  6. With -RemoveExistingCertificates, removes this server’s older certificates from Entra and the local store.
  7. Displays the tenant ID, client ID, and certificate thumbprint to enter in CertKit.

Creating the certificate first means a TPM failure leaves the tenant untouched, with no partially configured app registration or role. If the certificate never reaches Entra, because of an error or a declined confirmation prompt, the script deletes it from the local store so nothing is left behind. When the script finishes, it displays output similar to the following.

TenantName : Contoso
TenantId : 00000000-0000-0000-0000-000000000000
ClientId : 11111111-1111-1111-1111-111111111111
CertificateThumbprint : 0123456789ABCDEF0123456789ABCDEF01234567
CertificateSubject : CN=CertKit App Proxy Agent
CertificateEku : 1.3.6.1.5.5.7.3.2
CertificateExpires : 12/1/2027 2:00:15 PM
KeyStorageProvider : Microsoft Platform Crypto Provider
CustomRole : App Proxy Certificate Manager
RoleAssigned : Through PIM
OldCertificatesRemoved : 0
ExpiredCertificatesRemoved : 0
LocalCertificatesRemoved : 0
ExpiredSecretsRemoved : 0

CertKit needs three values from this output: TenantId, ClientId, and CertificateThumbprint. Skip ahead to Configure CertKit to complete the configuration. To learn more about the certificate and its options, or to configure certificate authentication manually, continue reading.

Certificate Details

The script creates a self-signed certificate with the following settings.

SettingValue
SubjectCN=CertKit App Proxy Agent, no subject alternative names
KeyRSA 2048, non-exportable
SignatureSHA256
Key usageDigital Signature
Enhanced key usageClient Authentication (1.3.6.1.5.5.7.3.2), or a custom OID
Validity365 days by default; 30, 90, or 180 days with -CertificateValidityDays
StoreCert:\LocalMachine\My

The key length is fixed at RSA 2048 because many TPMs don’t support larger RSA keys. The maximum lifetime is one year, which keeps rotation a practiced routine. With a TPM-protected key, the risk of key theft is low, so very short lifetimes add little. A 30-day lifetime is practical only if you automate rotation.

TPM Key Storage

The script first asks the Microsoft Platform Crypto Provider to create the private key in the TPM. If that fails, such as on a virtual machine without a vTPM or a server with the TPM disabled, the script displays a warning with the reason and stores the key using the Microsoft Software Key Storage Provider instead. A non-exportable software key resists normal export tools, but not a determined local administrator. If your security policy requires hardware-protected credentials, add -RequireTpm, which turns the fallback into an error before any changes are made to the tenant. The KeyStorageProvider value in the script output reports the provider actually holding the key.

New-CertKitAppProxyIdentity.ps1 -RequireTpm -UsePim

Note: If the TPM is cleared or the server’s motherboard is replaced, the private key is lost. Run the script again to issue a new certificate.

Custom EKU

By default, the certificate includes the Client Authentication enhanced key usage (EKU), which works for all deployments. If your organization has a registered IANA Private Enterprise Number (PEN), you can use -CustomEku to replace Client Authentication with an object identifier (OID) under your PEN. Entra doesn’t check the EKU when CertKit signs in. It only verifies the signature against the uploaded public key. A custom EKU documents the certificate’s purpose and prevents it from being used for general client authentication elsewhere. The script validates the OID format, but it can’t confirm the PEN belongs to you. Windows displays a private EKU as Unknown Key Usage, which is expected. The following example uses 32473, a PEN reserved for documentation. Replace it with your own.

New-CertKitAppProxyIdentity.ps1 -CustomEku 1.3.6.1.4.1.32473.1.1 -UsePim

Configuration Using the Entra Admin Center

The same configuration can be performed manually. The certificate must still be created with PowerShell on the CertKit agent server, but the rest can be done in the Microsoft Entra admin center.

Create the Certificate

To begin, open an elevated PowerShell window on the CertKit agent server and create the certificate using the following commands. The private key is created in the TPM using the Microsoft Platform Crypto Provider and marked non-exportable. To use a custom EKU, replace 1.3.6.1.5.5.7.3.2 with your PEN-based OID.

$CertParams = @{
Type = 'Custom'
Subject = 'CN=CertKit App Proxy Agent'
CertStoreLocation = 'Cert:\LocalMachine\My'
Provider = 'Microsoft Platform Crypto Provider'
KeyAlgorithm = 'RSA'
KeyLength = 2048
HashAlgorithm = 'SHA256'
KeyExportPolicy = 'NonExportable'
KeyUsage = 'DigitalSignature'
TextExtension = @('2.5.29.37={text}1.3.6.1.5.5.7.3.2')
NotAfter = (Get-Date).AddMonths(12)
}
$Cert = New-SelfSignedCertificate @CertParams
$Cert.Thumbprint

Record the thumbprint, which CertKit needs later. If the server doesn’t have a TPM, the command fails. Remove the Provider line to store the key using the software key storage provider instead.

Export the Public Key

Next, export the certificate’s public key to a file. The private key isn’t included, and because it’s non-exportable, it can’t be.

Export-Certificate -Cert $Cert -FilePath "$env:TEMP\CertKitAppProxyAgent.cer"

Create the App Registration and Custom Role

Now create the app registration, grant the Application.Read.All permission, and create and assign the custom role as described in the client secret post. Skip the step to create a client secret. If you’ve already configured an app registration for client secret authentication, you can reuse it.

Upload the Certificate

Finally, upload the public certificate to the app registration.

  1. Navigate to Entra ID > App registrations and select CertKit App Proxy Deployment.
  2. Navigate to Certificates & secrets > Certificates and click Upload certificate.
  3. Select the exported .cer file, enter a description, such as CertKit Agent – <computer name>, and click Add.
  4. Confirm the thumbprint displayed matches the one recorded earlier.
The Certificates tab of the CertKit app registration in the Entra admin center, showing the uploaded CertKit Agent certificate with its thumbprint, description, start date, and expiration date.

Configure CertKit

With the app registration and certificate in place, create a new deployment in CertKit using the Microsoft Entra Application Proxy (Certificate Auth) template for the agent running on the server where the certificate was created. Select the certificate to deploy, then enter the Entra tenant ID, App registration (client) ID, and App registration certificate thumbprint. The thumbprint is displayed in the script output, or you can find it on the certificate’s Details tab in the Certificates (Local Computer) management console (certlm.msc) under Personal > Certificates. Then list the App Proxy applications to update by name, separated by commas, or enter an asterisk (*) as an app list wildcard to update all of them. If you update all applications, be sure to use a wildcard or multi-SAN (subject alternative name) certificate that covers the external URL of every App Proxy application you want CertKit to manage.

A CertKit deployment using the Microsoft Entra Application Proxy (Certificate Auth) template, with the tenant ID, client ID, and app registration certificate thumbprint entered and the app list wildcard set to update all App Proxy applications.

Deploy and Validate

After saving the CertKit deployment, wait a few minutes for the role assignment and API permission to take effect, then run the deployment. A successful run shows CertKit signing in as the app registration using the authentication certificate’s thumbprint, then lists each App Proxy application, whether its external URL is covered by the certificate, and the thumbprint Entra reports after the update.

Update command output:
Microsoft Entra Application Proxy Deployment | Apps: *
[Step 1] Reading certificate...
Certificate: CN=*.example.net | Thumbprint: <redacted> | Expires: 2027-03-02
Covers: *.example.net, example.net
[Step 2] Signing in to Microsoft Graph...
Signed in as the app registration <redacted> using certificate <redacted> (tenant <redacted>)
Graph permissions: Application.Read.All
Warning: The identity has no Microsoft Graph permission to update apps. Unless an Entra role allows it, uploads will be refused. Grant the application permission Application.ReadWrite.OwnedBy (admin consented) and add the identity as an owner of each App Proxy app.
[Step 3] Finding App Proxy apps...
Found 7 App Proxy app(s)
App1 (https://app1.example.net/): covered by this certificate
Private Access App: skipped, a Global Secure Access (Private Access) app, which has no TLS certificate
App2 (https://app2.example.net/): covered by this certificate
App3 (https://app3.example.net/): covered by this certificate
App4 (https://app4.example.net/): covered by this certificate
App5 (https://app5.example.net/): covered by this certificate
App6 (https://app6.example.net/): covered by this certificate
[Step 4] Uploading certificate...
App1 (https://app1.example.net/): updated (Entra reports thumbprint <redacted>, expires 2027-03-02)
App2 (https://app2.example.net/): updated (Entra reports thumbprint <redacted>, expires 2027-03-02)
App3 (https://app3.example.net/): updated (Entra reports thumbprint <redacted>, expires 2027-03-02)
App4 (https://app4.example.net/): updated (Entra reports thumbprint <redacted>, expires 2027-03-02)
App5 (https://app5.example.net/): updated (Entra reports thumbprint <redacted>, expires 2027-03-02)
App6 (https://app6.example.net/): updated (Entra reports thumbprint <redacted>, expires 2027-03-02)
DONE | Updated 6 app(s), 0 already had the certificate. Entra takes a minute or two to start serving it.

CertKit displays a warning that the identity has no Graph permission to update apps, but you can safely ignore it, because the custom role grants that access. App Proxy can take several minutes to begin serving the new certificate. To confirm the certificate the endpoint is serving, use my Get-TlsCertificate PowerShell script, as described in the client secret post.

Get-TlsCertificate -Hostname app1.example.net

Certificate Rotation and Multiple Agent Servers

The authentication certificate must be rotated before it expires, or CertKit deployments will fail. Each time the script runs, it creates a new certificate, and you can rotate in one of two ways.

  • Two-step rotation. Run the script without additional switches, update CertKit with the new thumbprint, confirm a deployment succeeds, then delete the old certificate in the Entra admin center. There’s no downtime.
  • One-step rotation. Run the script with -RemoveExistingCertificates, which removes this server’s older certificates from Entra and deletes them locally, along with their private keys. CertKit deployments fail until it’s updated with the new thumbprint.

Expired certificates and client secrets are removed from the app registration automatically, and expired CertKit certificates are deleted from the local store, so cleanup happens with each run. Certificates are named after the server that created them in Entra, which lets multiple CertKit agent servers share a single app registration. Running the script on one server rotates only that server’s certificates and never touches another server’s. Certificates are identified by NetBIOS computer name, so be sure each agent server has a unique name. Also, if your tenant has an app management policy that limits credential lifetimes, it may reject a certificate with a longer validity period.

Migrating from Client Secret Authentication

Version 2.0 of the script includes two changes that may affect existing scripts or runbooks. First, certificate authentication is now the default, so running the script with no parameters creates a certificate and requires an elevated session on the CertKit agent server. Add -UseClientSecret to keep using client secrets. Second, client secrets are now limited to 12 months, down from 24, so -SecretExpirationMonths values greater than 12 are rejected. To move an existing deployment from a client secret to a certificate, use the following steps.

  1. On the CertKit agent server, run the script in an elevated session with the same -DisplayName and -RoleName used originally. The existing app registration and role are reused, a certificate is added, and the script warns that client secrets remain.
  2. Update the CertKit deployment to use certificate authentication with the new thumbprint, and confirm a deployment succeeds.
  3. Delete the old client secrets in the Entra admin center under Certificates & secrets > Client secrets.

Removing the Configuration

To remove the configuration, use my Remove-CertKitAppProxyIdentity.ps1 PowerShell script. The script removes the role assignments, deletes the app registration along with its certificates and secrets in Entra, and keeps the custom role if another identity still uses it. Beginning with version 1.3, the -RemoveLocalCertificates switch also deletes the app registration’s certificates and private keys from the CertKit agent server. Run it in an elevated session on the agent server.

.\Remove-CertKitAppProxyIdentity.ps1 -RemoveLocalCertificates

The script matches local certificates by thumbprint, so certificates belonging to any other CertKit app registration on the same server are left alone. Local certificates are deleted only after the app registration is deleted, so a declined prompt or a failure never breaks a working configuration. Use -WhatIf to preview the changes. If multiple agent servers share the app registration, the first server’s run deletes it, so the remaining servers can’t match thumbprints afterward. The script’s README on GitHub includes a command to clean them up manually.

Summary

Certificate authentication gives CertKit a credential that can’t leave the server it was created on. It provides stronger protection than a client secret without the Azure subscription, Azure Arc onboarding, and ongoing management a managed identity requires for servers outside Azure. It uses the same custom Entra role and read-only Application.Read.All permission as the other methods, so the configuration follows security best practices and enforces least privilege. With version 2.0 of New-CertKitAppProxyIdentity.ps1, the certificate, app registration, permissions, and role assignment are configured in a single run.

Additional Information

Getting Started with CertKit

Need help automating TLS certificate deployment for Entra Application Proxy, Always On VPN, DirectAccess, IIS, SQL, and more? I can help you design and implement a secure, least-privilege certificate automation strategy with CertKit across your internal and public-facing workloads. Fill out the form below, and I’ll provide you with more information.

← Back

Thank you for your response. ✨

Automating Entra App Proxy Certificates with CertKit (Managed Identity)

Microsoft Entra ID icon

In a recent post, I described how to configure CertKit to automatically deploy renewed TLS certificates to Microsoft Entra Application Proxy applications using an Entra app registration with client secret authentication. That method works anywhere, but it relies on a client secret that must be stored securely and rotated before it expires. When the CertKit agent runs on an Azure virtual machine or an Azure Arc-enabled server, CertKit can authenticate with a managed identity instead, eliminating the client secret entirely. This configuration uses the same least-privilege permissions as the client secret method. The following sections describe how to configure it using both PowerShell and the Azure portal. CertKit also supports certificate authentication, which protects the private key with a TPM and works on any Windows server without Azure. It’s my recommended approach when the CertKit agent doesn’t run in Azure.

Why Use a Managed Identity

A managed identity is an identity in Microsoft Entra ID that Azure manages on behalf of an Azure resource. It offers several advantages over a client secret, including the following.

  • No secret to manage. There’s no client secret to store, protect, or rotate, and no expiration date that can unexpectedly break certificate deployments.
  • Bound to a specific resource. The identity can only be used from the Azure resource it’s attached to. It can’t be copied out of a configuration file or password vault and used elsewhere.
  • Aligned with Microsoft guidance. Microsoft recommends managed identities over client secrets for workloads that support them.

There are tradeoffs, however. A managed identity is available only to Azure resources, so the CertKit agent must run on an Azure virtual machine or a server onboarded to Azure Arc. In addition, anyone who compromises that server can request tokens as the managed identity. Least privilege limits the impact, just as it does with a client secret. Managed identity authentication is a good choice when the CertKit agent already runs on an Azure virtual machine. For servers outside Azure, onboarding them to Azure Arc solely for CertKit adds management overhead, so certificate authentication is the better choice. It protects the private key with a TPM and doesn’t require an Azure subscription.

Requirements

Using a managed identity with CertKit requires the following.

  • An Azure virtual machine or Azure Arc-enabled server. The CertKit agent must run on a server with a managed identity. Azure virtual machines support managed identities natively and don’t require Azure Arc. On-premises servers, or servers hosted in other clouds, must be onboarded to Azure Arc. The server doesn’t need to be domain-joined.
  • An Azure subscription in the same tenant. The Azure subscription must be associated with the same Microsoft Entra tenant where Application Proxy is configured.
  • Outbound internet access. The CertKit agent requires outbound HTTPS access to CertKit and Microsoft Graph. No inbound access or public IP address is required.
  • The Microsoft Graph PowerShell module on the agent host. The CertKit agent uses the Microsoft.Graph.Authentication module to sign in with the managed identity. Since the agent runs as Local System, the module must be installed for all users.
  • Microsoft Entra ID P1. This is already required for Application Proxy and custom roles. Assigning the role through Privileged Identity Management (PIM) requires Microsoft Entra ID P2 or Microsoft Entra ID Governance.

I recommend using a user-assigned managed identity. It’s a standalone Azure resource dedicated to CertKit, and it persists if the virtual machine is rebuilt or replaced. Azure Arc-enabled servers support only a system-assigned managed identity, which is shared with the Azure Arc agent and other services on the server.

Required Permissions for CertKit

The managed identity requires the same least-privilege permissions as the client secret method, including the following.

  • Application.Read.All. A read-only Microsoft Graph application permission CertKit uses to find App Proxy applications in the tenant.
  • A custom Entra role. A custom role, named App Proxy Certificate Manager in this example, with only three permissions: read Application Proxy settings, update the Application Proxy SSL certificate, and read connector groups.

This configuration follows security best practices and enforces least privilege. The managed identity can’t add credentials to applications, change API permissions, or grant consent. For more details on these permissions and why built-in roles such as Application Administrator should be avoided, see the client secret post. If you’ve already created the custom role for another authentication method, you can reuse it.

Create the Managed Identity

A user-assigned managed identity is an Azure resource, so it’s created in the Azure portal rather than the Entra admin center. Create it and attach it to the virtual machine running the CertKit agent using the following steps.

Create the User-Assigned Managed Identity

To begin, create the managed identity.

  1. In the Azure portal, search for Managed Identities and click Create.
  2. Select the subscription, resource group, and region, and enter a name, such as certkit-app-proxy.
  3. Click Review + create, then Create.
  4. On the managed identity’s Overview page, record the Client ID. CertKit and the configuration script both use this value.
The Overview page of the certkit-app-proxy user-assigned managed identity in the Azure portal, with an arrow pointing to the Client ID.

Attach the Managed Identity to the Virtual Machine

Next, attach the managed identity to the virtual machine running the CertKit agent.

  1. Open the virtual machine and navigate to Security > Identity.
  2. Select the User assigned tab and click Add.
  3. Select the managed identity and click Add.
The User assigned tab of the virtual machine's Identity page in the Azure portal, showing the certkit-app-proxy managed identity attached.

Alternatively, attach the managed identity using the Azure CLI in Azure Cloud Shell. Replace the resource group, virtual machine name, and managed identity resource ID with your own. The resource ID is shown on the managed identity’s Properties page.

az vm identity assign --resource-group <resourceGroup> --name <vmName> --identities <managedIdentityResourceId>

Install the Microsoft Graph PowerShell Module on the Agent Host

With managed identity authentication, the CertKit agent signs in to Microsoft Graph locally on the server using the Microsoft.Graph.Authentication PowerShell module. The agent runs as Local System, so the module must be installed for all users. On the server running the CertKit agent, open an elevated Windows PowerShell command window and run the following command.

Install-Module -Name Microsoft.Graph.Authentication -Scope AllUsers -Repository PSGallery -Force

Be sure to use Windows PowerShell, not PowerShell 7. The two use separate module locations, and the CertKit agent uses Windows PowerShell. If the module is missing, CertKit deployments fail with an error indicating that Microsoft.Graph.Authentication is not installed.

Configuration Using PowerShell

You can grant the managed identity its permissions in a single run using my New-CertKitAppProxyIdentity.ps1 PowerShell script on GitHub. Specify the managed identity’s client ID with the -ManagedIdentityId parameter, and the script creates the custom role if it doesn’t already exist, grants Application.Read.All, and assigns the role. Add -UsePim to assign the role through PIM, and -TenantId if your account has access to more than one tenant. The script confirms the identity is a managed identity before making any changes. Alternatively, follow the manual steps below, which show exactly what the script does. Either way, you’ll need the Microsoft.Graph.Authentication module on your workstation. Install it using the following command.

Install-Module -Name Microsoft.Graph.Authentication -Scope CurrentUser

Then run the script, replacing <clientId> with the managed identity’s client ID.

New-CertKitAppProxyIdentity.ps1 -ManagedIdentityId <clientId> -UsePim

When the script finishes, it displays the managed identity’s name and client ID. Skip ahead to Configure CertKit to complete the configuration. To configure the managed identity manually instead, follow the steps below.

Connect to Microsoft Graph

First, connect to Microsoft Graph with an account that can create custom roles, grant application permissions, and assign directory roles, such as Privileged Role Administrator or Global Administrator. If your account has access to more than one tenant, add -TenantId with the tenant ID or domain name to sign in to the correct tenant.

Connect-MgGraph -Scopes 'Application.Read.All', 'AppRoleAssignment.ReadWrite.All', 'RoleManagement.ReadWrite.Directory' -NoWelcome

Find the Managed Identity

Next, find the managed identity’s service principal using its client ID. Confirm that servicePrincipalType is ManagedIdentity before continuing.

$Mi = (Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/v1.0/servicePrincipals?`$filter=appId eq '<clientId>'&`$select=id,appId,displayName,servicePrincipalType").value[0]
$Mi

Create the Custom Role

If you haven’t already created the custom role for another authentication method, create it now. Otherwise, retrieve the existing role.

$RoleBody = @{
displayName = 'App Proxy Certificate Manager'
description = 'Can read Application Proxy settings and update the Application Proxy SSL certificate. Used by CertKit.'
isEnabled = $true
rolePermissions = @(@{
allowedResourceActions = @(
'microsoft.directory/applications/applicationProxy/read'
'microsoft.directory/applications/applicationProxySslCertificate/update'
'microsoft.directory/connectorGroups/allProperties/read'
)
})
}
$Role = Invoke-MgGraphRequest -Method POST -Uri 'https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions' -Body $RoleBody

To retrieve an existing role instead, use the following command.

$Role = (Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions?`$filter=displayName eq 'App Proxy Certificate Manager'").value[0]

Grant the Application.Read.All Permission

Next, grant the managed identity the read-only Microsoft Graph application permission Application.Read.All. Assigning the permission this way also grants admin consent.

$GraphSp = (Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/v1.0/servicePrincipals?`$filter=appId eq '00000003-0000-0000-c000-000000000000'&`$select=id,appRoles").value[0]
$AppRoleId = ($GraphSp.appRoles | Where-Object { $_.value -eq 'Application.Read.All' -and $_.allowedMemberTypes -contains 'Application' }).id
$Grant = @{
principalId = $Mi.id
resourceId = $GraphSp.id
appRoleId = $AppRoleId
}
Invoke-MgGraphRequest -Method POST -Uri "https://graph.microsoft.com/v1.0/servicePrincipals/$($Mi.id)/appRoleAssignments" -Body $Grant

Assign the Custom Role

Finally, assign the custom role to the managed identity, scoped to the entire tenant.

$Body = @{
'@odata.type' = '#microsoft.graph.unifiedRoleAssignment'
roleDefinitionId = $Role.id
principalId = $Mi.id
directoryScopeId = '/'
}
Invoke-MgGraphRequest -Method POST -Uri 'https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignments' -Body $Body

If your tenant is licensed for Microsoft Entra ID P2 or Microsoft Entra ID Governance, assign the role through Privileged Identity Management (PIM) instead. Role assignments made outside PIM aren’t tracked by PIM and trigger a high-severity alert. Managed identities support only active assignments in PIM, so the following command creates a permanent active assignment. If the custom role was just created, PIM can take several minutes to recognize it. If the command fails with a RoleNotFound error, wait a few minutes and try again.

$Body = @{
action = 'adminAssign'
justification = 'CertKit certificate deployment to Entra Application Proxy'
roleDefinitionId = $Role.id
directoryScopeId = '/'
principalId = $Mi.id
scheduleInfo = @{
startDateTime = (Get-Date).ToUniversalTime().ToString('o')
expiration = @{ type = 'noExpiration' }
}
}
Invoke-MgGraphRequest -Method POST -Uri 'https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignmentScheduleRequests' -Body $Body

Configuration Using the Entra Admin Center

The Microsoft Entra admin center can’t grant Microsoft Graph application permissions to a managed identity, so the Application.Read.All permission must be granted using PowerShell, as shown above. The custom role can be created and assigned in the Entra admin center, however. Create the custom role as described in the client secret post if it doesn’t already exist, then assign it using the following steps.

  1. Navigate to Entra ID > Roles & admins, then search for and select App Proxy Certificate Manager.
  2. Click Add assignments, then Select member(s).
  3. Search for the managed identity by name, select it, and click Select.
  4. If Privileged Identity Management (PIM) is enabled, click Next, set the assignment type to Active and Permanently assigned, enter a justification, and click Assign. Without PIM, click Add.

Configure CertKit

With the managed identity configured, create a new deployment in CertKit using the Microsoft Entra Application Proxy (Managed Identity Auth) template for the agent running on the virtual machine. Select the certificate to deploy, then enter the user-assigned managed identity’s client ID in the Managed identity field. To use a system-assigned managed identity instead, such as on an Azure Arc-enabled server, leave the field set to system. No tenant ID or client secret is required. Then list the App Proxy applications to update by name, separated by commas, or enter an asterisk (*) as an app list wildcard to update all of them. If you update all applications, be sure to use a wildcard or multi-SAN certificate that covers the external URL of every App Proxy application you want CertKit to manage.

A CertKit deployment using the Microsoft Entra Application Proxy (Managed Identity Auth) template, with the managed identity client ID entered and the app list wildcard set to update all App Proxy applications.

Deploy and Validate

After saving the CertKit deployment, wait a few minutes for the role assignment and API permission to take effect, then run the deployment. A successful run shows CertKit signing in as the user-assigned managed identity, then lists each App Proxy application, whether its external URL is covered by the certificate, and the thumbprint Entra reports after the update.

Update command output:
Microsoft Entra Application Proxy Deployment | Apps: *
[Step 1] Reading certificate...
Certificate: | Thumbprint: <redacted> | Expires: 2026-11-30
Covers: *.example.net, example.net
[Step 2] Signing in to Microsoft Graph...
Signed in as the user-assigned managed identity <redacted> (tenant <redacted>)
Graph permissions: Application.Read.All
Warning: The identity has no Microsoft Graph permission to update apps. Unless an Entra role allows it, uploads will be refused. Grant the application permission Application.ReadWrite.OwnedBy (admin consented) and add the identity as an owner of each App Proxy app.
[Step 3] Finding App Proxy apps...
Found 8 App Proxy app(s)
App1 (https://app1.example.net/): covered by this certificate
Private Access App 1: skipped, a Global Secure Access (Private Access) app, which has no TLS certificate
Private Access App 2: skipped, a Global Secure Access (Private Access) app, which has no TLS certificate
App2 (https://app2.example.net/): covered by this certificate
App3 (https://app3.example.net/): covered by this certificate
App4 (https://app4.example.net/): covered by this certificate
App5 (https://app5.example.net/): covered by this certificate
App6 (https://app6.example.net/): covered by this certificate
[Step 4] Uploading certificate...
App1 (https://app1.example.net/): updated (Entra reports thumbprint <redacted>, expires 2026-11-30)
App2 (https://app2.example.net/): updated (Entra reports thumbprint <redacted>, expires 2026-11-30)
App3 (https://app3.example.net/): updated (Entra reports thumbprint <redacted>, expires 2026-11-30)
App4 (https://app4.example.net/): updated (Entra reports thumbprint <redacted>, expires 2026-11-30)
App5 (https://app5.example.net/): updated (Entra reports thumbprint <redacted>, expires 2026-11-30)
App6 (https://app6.example.net/): updated (Entra reports thumbprint <redacted>, expires 2026-11-30)
DONE | Updated 6 app(s), 0 already had the certificate. Entra takes a minute or two to start serving it.

CertKit displays a warning that the identity has no Graph permission to update apps, but you can safely ignore it, because the custom role grants that access. App Proxy can take several minutes to begin serving the new certificate. To confirm the certificate the endpoint is serving, use my Get-TlsCertificate PowerShell script, as described in the client secret post.

Get-TlsCertificate -Hostname app1.example.net

Removing the Configuration

To remove CertKit’s permissions from the managed identity, use my Remove-CertKitAppProxyIdentity.ps1 PowerShell script with the -ManagedIdentityId parameter. The script removes the role assignment and the Application.Read.All permission. It doesn’t delete the managed identity, which is an Azure resource, and it keeps the custom role if another identity still uses it. This makes it safe to move between authentication methods, for example from a managed identity to certificate authentication, without breaking another deployment that uses the same role.

.\Remove-CertKitAppProxyIdentity.ps1 -ManagedIdentityId <clientId>

Summary

When the CertKit agent runs on an Azure virtual machine or an Azure Arc-enabled server, a managed identity eliminates the client secret, removing the need to store, protect, and rotate it. The managed identity uses the same custom Entra role and read-only Application.Read.All permission as the client secret method, so this configuration follows security best practices and enforces least privilege. For servers outside Azure, certificate authentication also eliminates the client secret, using a TPM-protected private key without requiring Azure Arc.

Additional Information

Getting Started with CertKit

Need help automating TLS certificate deployment for Entra Application Proxy, Always On VPN, DirectAccess, IIS, SQL, and more? I can help you design and implement a secure, least-privilege certificate automation strategy with CertKit across your internal and public-facing workloads. Fill out the form below, and I’ll provide you with more information.

← Back

Thank you for your response. ✨

Automating Entra App Proxy Certificates with CertKit (Client Secret)

Microsoft Entra ID icon

Microsoft Entra Application Proxy applications published with custom domains require a public TLS certificate, and keeping those certificates current is a manual, error-prone task when done in the Entra admin center. With the industry moving to 47-day public TLS certificates by 2029, automation is quickly becoming a requirement rather than a convenience. I recently configured CertKit to automatically deploy renewed certificates to my Entra App Proxy applications using an Entra app registration with client secret authentication. This configuration follows security best practices and enforces least privilege, granting CertKit only the access it needs to find App Proxy applications and update their certificates. The following sections describe how to configure it using both PowerShell and the Entra admin center. CertKit also supports managed identity authentication, which I cover in Automating Entra App Proxy Certificates with CertKit (Managed Identity), and certificate authentication, which I cover in Automating Entra App Proxy Certificates with CertKit (Certificate Authentication). Certificate authentication replaces the client secret with a TPM-protected private key that can’t be copied, and it’s now my recommended approach for most deployments.

CertKit Deployment Options

CertKit can deploy a certificate to Entra App Proxy in one of two ways.

  • Individual applications. CertKit updates only the App Proxy applications you specify.
  • All applications. CertKit enumerates every App Proxy application in the tenant, determines which ones have an external URL covered by the certificate, and updates each of them.

If you choose to update all applications, be sure to use a wildcard or multi-SAN (subject alternative name) certificate that covers the external URL of every App Proxy application you want CertKit to manage. CertKit updates only applications whose external URL matches a name on the certificate, so a certificate with a single name updates only the application that uses that name. CertKit also skips Global Secure Access (Private Access) applications, such as Enterprise Quick Access. These applications appear alongside App Proxy applications, but they don’t use a TLS certificate, so there’s nothing to update.

Why 6-Day Certificates

In my lab, I’m using Let’s Encrypt’s short-lived 6-day certificates. Testing and evaluating certificate automation is much easier with short-lived certificates, because renewals happen every few days rather than every few months. Any problem with the renewal or deployment process shows up quickly, and I can confirm the automation works reliably across many renewal cycles in a short time. Short-lived certificates leave little margin for error, though, so I don’t recommend them in production until the automation is proven.

Required Permissions for CertKit

Create a dedicated Entra app registration for CertKit. CertKit uses this identity to sign in to Microsoft Graph, and it requires only the following permissions.

  • Application.Read.All. A read-only Microsoft Graph application permission CertKit uses to find App Proxy applications in the tenant.
  • A custom Entra role. A custom role, named App Proxy Certificate Manager in this example, with only three permissions: read Application Proxy settings, update the Application Proxy SSL certificate, and read connector groups.

This configuration enforces least privilege. Built-in roles such as Application Administrator also work, but they grant far more access than CertKit needs, including the ability to add credentials to any application in the tenant, a well-known privilege escalation path. With the custom role, CertKit can’t add credentials, change API permissions, or grant consent. Custom roles require Microsoft Entra ID P1, which is already required for Application Proxy. CertKit displays a warning that the identity has no Graph permission to update apps, but you can safely ignore it, because the custom role grants that access.

Configuration Using PowerShell

You can perform this configuration in a single run using my New-CertKitAppProxyIdentity.ps1 PowerShell script on GitHub, which creates the app registration, custom Entra role, Application.Read.All permission, role assignment, and client secret for CertKit. If your account has access to more than one tenant, use the -TenantId parameter to specify the tenant to configure. The script displays the connected tenant before making any changes. Alternatively, follow the manual steps below, which show exactly what the script does. Either way, you’ll need the Microsoft.Graph.Authentication module from the Microsoft Graph PowerShell SDK, since every call uses Invoke-MgGraphRequest. Install it using the following command.

Install-Module -Name Microsoft.Graph.Authentication -Scope CurrentUser

To use the script, run New-CertKitAppProxyIdentity.ps1 -UseClientSecret, adding -UsePim to assign the role through PIM. Beginning with version 2.0, the script uses certificate authentication by default, so -UseClientSecret is required to create a client secret. Client secrets are limited to a maximum of 12 months, and you can choose a shorter period with -SecretExpirationMonths. When the script finishes, it copies the client secret to the clipboard and displays the tenant ID and client ID. Skip ahead to Configure CertKit to complete the configuration. To configure the app registration manually instead, follow the steps below.

Connect to Microsoft Graph

First, connect to Microsoft Graph with an account that can create custom roles, grant application permissions, and assign directory roles, such as Privileged Role Administrator or Global Administrator. If your account has access to more than one tenant, add -TenantId with the tenant ID or domain name to sign in to the correct tenant.

Connect-MgGraph -Scopes 'Application.ReadWrite.All', 'AppRoleAssignment.ReadWrite.All', 'RoleManagement.ReadWrite.Directory' -NoWelcome

Create the App Registration

Next, create a dedicated app registration for CertKit. The command displays the application (client) ID, which CertKit needs later.

$NewApp = Invoke-MgGraphRequest -Method POST -Uri 'https://graph.microsoft.com/v1.0/applications' -Body @{ displayName = 'CertKit App Proxy Deployment'; signInAudience = 'AzureADMyOrg' }
$NewApp.appId

Create the Service Principal

App registrations created with Graph don’t get a service principal automatically, so create one. The role and API permission are assigned to the service principal, not the app registration.

$NewSp = Invoke-MgGraphRequest -Method POST -Uri 'https://graph.microsoft.com/v1.0/servicePrincipals' -Body @{ appId = $NewApp.appId }

Create the Custom Role

Now create a custom role that can only read Application Proxy settings and update the Application Proxy SSL certificate.

$RoleBody = @{
displayName = 'App Proxy Certificate Manager'
description = 'Can read Application Proxy settings and update the Application Proxy SSL certificate. Used by CertKit.'
isEnabled = $true
rolePermissions = @(@{
allowedResourceActions = @(
'microsoft.directory/applications/applicationProxy/read'
'microsoft.directory/applications/applicationProxySslCertificate/update'
'microsoft.directory/connectorGroups/allProperties/read'
)
})
}
$Role = Invoke-MgGraphRequest -Method POST -Uri 'https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions' -Body $RoleBody

Grant the Application.Read.All Permission

Next, grant the service principal the read-only Microsoft Graph application permission Application.Read.All. Assigning the permission this way also grants admin consent.

$GraphSp = (Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/v1.0/servicePrincipals?`$filter=appId eq '00000003-0000-0000-c000-000000000000'&`$select=id,appRoles").value[0]
$AppRoleId = ($GraphSp.appRoles | Where-Object { $_.value -eq 'Application.Read.All' -and $_.allowedMemberTypes -contains 'Application' }).id
$Grant = @{
principalId = $NewSp.id
resourceId = $GraphSp.id
appRoleId = $AppRoleId
}
Invoke-MgGraphRequest -Method POST -Uri "https://graph.microsoft.com/v1.0/servicePrincipals/$($NewSp.id)/appRoleAssignments" -Body $Grant

Assign the Custom Role

Now assign the custom role to the service principal, scoped to the entire tenant.

$Body = @{
'@odata.type' = '#microsoft.graph.unifiedRoleAssignment'
roleDefinitionId = $Role.id
principalId = $NewSp.id
directoryScopeId = '/'
}
Invoke-MgGraphRequest -Method POST -Uri 'https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignments' -Body $Body

If your tenant is licensed for Microsoft Entra ID P2 or Microsoft Entra ID Governance, assign the role through Privileged Identity Management (PIM) instead. Role assignments made outside PIM aren’t tracked by PIM and trigger a high-severity alert. Service principals support only active assignments in PIM, so the following command creates a permanent active assignment.

$Body = @{
action = 'adminAssign'
justification = 'CertKit certificate deployment to Entra Application Proxy'
roleDefinitionId = $Role.id
directoryScopeId = '/'
principalId = $NewSp.id
scheduleInfo = @{
startDateTime = (Get-Date).ToUniversalTime().ToString('o')
expiration = @{ type = 'noExpiration' }
}
}
Invoke-MgGraphRequest -Method POST -Uri 'https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignmentScheduleRequests' -Body $Body

Create the Client Secret

Finally, create a client secret. I’ve chosen a 1-year expiration, which I recommend as the maximum. To use a shorter period, change the AddYears(1) value, for example to AddMonths(6) for a 6-month expiration. The secret is copied to the clipboard rather than displayed on screen, which keeps it out of console history and screen recordings. The secret value can’t be retrieved later, so paste it into CertKit right away.

$Params = @{
passwordCredential = @{
displayName = 'CertKit'
endDateTime = (Get-Date).AddYears(1).ToString('o')
}
}
$Secret = Invoke-MgGraphRequest -Method POST -Uri "https://graph.microsoft.com/v1.0/applications/$($NewApp.id)/addPassword" -Body $Params
$Secret.secretText | Set-Clipboard

After pasting the secret into CertKit, clear the clipboard.

Set-Clipboard -Value $null

Configuration Using the Entra Admin Center

The same configuration can be performed in the Microsoft Entra admin center using an account that can create custom roles, grant application permissions, and assign directory roles, such as Privileged Role Administrator or Global Administrator.

Create the App Registration

To begin, create the app registration. The admin center creates the service principal (enterprise application) automatically.

  1. Navigate to Entra ID > App registrations and click New registration.
  2. Enter CertKit App Proxy Deployment for the name.
  3. Select Accounts in this organizational directory only.
  4. Leave the redirect URI blank and click Register.
  5. On the Overview page, record the Application (client) ID and Directory (tenant) ID.
The Overview page of the CertKit App Proxy Deployment app registration, showing the Application (client) ID and Directory (tenant) ID.

Grant the Application.Read.All Permission

Next, grant the app registration the read-only Application.Read.All permission.

  1. In the app registration, navigate to API permissions. Select the delegated User.Read permission the admin center adds by default and click Remove permission, since CertKit doesn’t use it.
  2. Click Add a permission, then Microsoft Graph > Application permissions.
  3. Search for and select Application.Read.All, then click Add permissions.
  4. Click Grant admin consent for your tenant and click Yes.

Create the Client Secret

Next, create a client secret for CertKit to authenticate with. I’ve chosen a 1-year expiration, which I recommend as the maximum, but you can choose a shorter period as you see fit.

  1. In the app registration, navigate to Certificates & secrets > Client secrets and click New client secret.
  2. Enter CertKit for the description and select 365 days (12 months) for the expiration.
  3. Click Add, then copy the Value immediately. Don’t copy the Secret ID. The value is displayed only once.

Create the Custom Role

Now create the custom role.

  1. Navigate to Entra ID > Roles & admins and click New custom role.
  2. Enter App Proxy Certificate Manager for the name, add a description, and click Next.
  3. On the Permissions page, search for and select microsoft.directory/applications/applicationProxy/read, microsoft.directory/applications/applicationProxySslCertificate/update, and microsoft.directory/connectorGroups/allProperties/read, then click Next.
  4. Review the settings and click Create.

Assign the Custom Role

Finally, assign the custom role to the new identity.

  1. Navigate to Entra ID > Roles & admins, then search for and select App Proxy Certificate Manager.
  2. Click Add assignments, then Select member(s).
  3. Search for CertKit App Proxy Deployment, select it, and click Select.
  4. If Privileged Identity Management (PIM) is enabled, click Next, set the assignment type to Active and Permanently assigned, enter a justification, and click Assign. Without PIM, click Add.
The App Proxy Certificate Manager role's Active assignments tab in Privileged Identity Management, showing CertKit App Proxy Deployment permanently assigned as a service principal.

Configure CertKit

With the app registration in place, create a new deployment in CertKit using the Microsoft Entra Application Proxy (Client Secret Auth) template. Select the certificate to deploy, and enter the directory (tenant) ID, application (client) ID, and client secret from the app registration. Then list the App Proxy applications to update by name, separated by commas, or enter an asterisk (*) as an app list wildcard to update all of them.

A CertKit deployment using the Microsoft Entra Application Proxy (Client Secret Auth) template, with the wildcard set to update all App Proxy applications.

Deploy and Validate

After saving the CertKit deployment and deploying the changes, wait a few minutes for the role assignment and API permission to take effect, then run the deployment. A successful run lists each App Proxy application, whether its external URL is covered by the certificate, and the thumbprint Entra reports after the update.

Update command output:
Microsoft Entra Application Proxy Deployment | Apps: *
[Step 1] Reading certificate...
Certificate: | Thumbprint: <redacted> | Expires: 2026-11-21
Covers: *.example.net, example.net
[Step 2] Signing in to Microsoft Graph...
Signed in as the app registration <redacted> (tenant <redacted>)
Graph permissions: Application.Read.All
Warning: The identity has no Microsoft Graph permission to update apps. Unless an Entra role allows it, uploads will be refused. Grant the application permission Application.ReadWrite.OwnedBy (admin consented) and add the identity as an owner of each App Proxy app.
[Step 3] Finding App Proxy apps...
Found 7 App Proxy app(s)
App1 (https://app1.example.net/): covered by this certificate
Private Access App: skipped, a Global Secure Access (Private Access) app, which has no TLS certificate
App2 (https://app2.example.net/): covered by this certificate
App3 (https://app3.example.net/): covered by this certificate
App4 (https://app4.example.net/): covered by this certificate
App5 (https://app5.example.net/): covered by this certificate
App6 (https://app6.example.net/): covered by this certificate
[Step 4] Uploading certificate...
App1 (https://app1.example.net/): updated (Entra reports thumbprint <redacted>, expires 2026-11-21)
App2 (https://app2.example.net/): updated (Entra reports thumbprint <redacted>, expires 2026-11-21)
App3 (https://app3.example.net/): updated (Entra reports thumbprint <redacted>, expires 2026-11-21)
App4 (https://app4.example.net/): updated (Entra reports thumbprint <redacted>, expires 2026-11-21)
App5 (https://app5.example.net/): updated (Entra reports thumbprint <redacted>, expires 2026-11-21)
App6 (https://app6.example.net/): updated (Entra reports thumbprint <redacted>, expires 2026-11-21)
DONE | Updated 6 app(s), 0 already had the certificate. Entra takes a minute or two to start serving it.

Validate the Entra Configuration

To confirm Entra stored the new certificate, open the application in Entra ID > Enterprise applications and select Application proxy, or query the application’s App Proxy settings with PowerShell. Replace <objectId> with the app registration’s object ID.

The SSL certificate pane of an App Proxy application, showing the certificate's subject, thumbprint, and expiration date.
$Uri = "https://graph.microsoft.com/beta/applications/<objectId>?`$select=onPremisesPublishing"
(Invoke-MgGraphRequest -Method GET -Uri $Uri).onPremisesPublishing.verifiedCustomDomainCertificatesMetadata.thumbprint

Validate the Live Endpoint

App Proxy can take several minutes to begin serving the new certificate after the configuration is updated. To check the certificate the endpoint is actually serving, view it in a browser or use my Get-TlsCertificate PowerShell script.

Get-TlsCertificate is available in the PowerShell Gallery and on GitHub. Install it using the following command.

Install-Script -Name Get-TlsCertificate

Once installed, run it against the application’s external hostname.

Get-TlsCertificate -Hostname app1.example.net
Output of Get-TlsCertificate showing the certificate served by the App Proxy endpoint, including its issuer, thumbprint, expiration date, and subject alternative names.

The expiration date CertKit displays may differ by one day from the date Entra reports. That’s expected, because Entra reports dates in UTC.

Secret Rotation and Security

The client secret must be rotated before it expires, or CertKit deployments will fail. To rotate it, create a new secret on the app registration, update CertKit with the new value, confirm a deployment succeeds, and then delete the old secret. You can also rotate it with the script by running New-CertKitAppProxyIdentity.ps1 -UseClientSecret again, which creates a new secret and automatically removes any expired ones. Adding -RemoveExistingSecrets also removes the old valid secrets once the new one exists, so update CertKit right away. Set a calendar reminder well ahead of the expiration date. Least privilege limits the impact if the secret is ever exposed. Anyone holding it could replace the TLS certificate on App Proxy applications and read app registration details, but couldn’t add credentials to other applications, change permissions, or grant consent. Even so, store the secret securely and limit who can access it. To eliminate the secret entirely, consider certificate authentication, which uses a TPM-protected private key that can’t be copied off the CertKit agent server. The same post describes how to migrate from a client secret without downtime.

Summary

CertKit can fully automate certificate deployment to Entra Application Proxy, either for individual applications or for every App Proxy application in the tenant. By combining a custom Entra role limited to App Proxy certificate updates with the read-only Application.Read.All permission, this configuration follows security best practices and enforces least privilege, without the broad access of built-in roles such as Application Administrator. Using short-lived 6-day certificates makes it easy to confirm the automation works, and rotating the client secret before it expires keeps the deployment running. For stronger protection, certificate authentication replaces the client secret with a TPM-protected private key and is now my recommended approach.

Additional Information

Getting Started with CertKit

Need help automating TLS certificate deployment for Entra Application Proxy, Always On VPN, DirectAccess, IIS, SQL, and more? I can help you design and implement a secure, least-privilege certificate automation strategy with CertKit across your internal and public-facing workloads. Fill out the form below, and I’ll provide you with more information.

← Back

Thank you for your response. ✨