<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content

Okta Active Directory Agent PowerShell Script Fails Due to Certificate Issue

Okta Classic Engine
Okta Identity Engine
Directories

Overview

An HTTP 400 error occurs when Okta invokes a PowerShell script in Active Directory (AD) via the Okta AD Agent. This happens because the self-signed certificate resides in the user store instead of the LocalMachine store. Moving the signing certificate to the LocalMachine store resolves the error.

 

"kind": "HTTP Request Error",
"statusCode": 400,

 

Applies To

  • Okta Identity Engine (OIE)
  • Okta Classic Engine
  • Active Directory (AD) Agent
  • PowerShell Scripts

Cause

The self-signed certificate resides in the user store rather than the LocalMachine store.

Solution

How is the certificate issue resolved?

The signing certificate and the intermediate or root Certificate Authority (CA) certificates must be placed in the LocalMachine store. The Root CA, or Self-Signed Root, must be placed in the Trusted Root Certification Authorities store. Authenticode signature trust across service accounts and background processes requires the Code Signing Certificate in the Trusted Publishers store.

 

Move the Signing Certificate to the Correct Store Using PowerShell

Place the signing certificate and the intermediate or root CA certificates in the LocalMachine store by executing the following PowerShell commands.

  1. Open an elevated PowerShell window on the AD Agent server.
  2. Import the Root CA into the LocalMachine Root store and the Code Signing Certificate into the LocalMachine TrustedPublishers store by running the following script:
    # 1. Import the Root CA into the LocalMachine Root store
    $rootStore = [System.Security.Cryptography.X509Certificates.X509Store]::new("Root", "LocalMachine")
    $rootStore.Open("ReadWrite")
    $rootStore.Add($cert)
    $rootStore.Close()
    
    # 2. Import the Code Signing Certificate into the LocalMachine TrustedPublishers store
    $pubStore = [System.Security.Cryptography.X509Certificates.X509Store]::new("TrustedPublisher", "LocalMachine")
    $pubStore.Open("ReadWrite")
    $pubStore.Add($cert)
    $pubStore.Close()
Loading
Okta Active Directory Agent PowerShell Script Fails Due to Certificate Issue | Okta Support