> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/m/microsoft-ca.md).

# Microsoft CA

Microsoft CA (Active Directory Certificate Services) issues certificates inside a Windows domain. OctoXLabs runs `certutil` over WinRM on the CA host and adds the issued certificates to the certificate inventory.

## Use cases

* Find issued certificates that are about to expire.

```
Adapters = microsoft-ca AND ExpiryStatus = expiring
```

* Find certificates that already expired.

```
Adapters = microsoft-ca AND ExpiryStatus = expired
```

## Before you begin

### Network

| Source              | Destination               | Port                        | Protocol      |
| ------------------- | ------------------------- | --------------------------- | ------------- |
| OctoXLabs connector | Microsoft CA host (WinRM) | 5985 (HTTP) or 5986 (HTTPS) | HTTP or HTTPS |

### Required permissions

| Scope or role                 | Permission        | Needed for                                |
| ----------------------------- | ----------------- | ----------------------------------------- |
| Remote Management Users group | Remote PowerShell | Running `certutil` queries on the CA host |

The account must be in the Remote Management Users group and be allowed to open remote PowerShell sessions. Microsoft KB5005413 recommends Kerberos for AD CS hosts. If the environment rejects NTLM, set Auth Type to Kerberos, Is Secure to on and Port to 5986.

## Create credentials in Microsoft CA

{% stepper %}
{% step %}

### Create an account

Create a domain account for OctoXLabs.
{% endstep %}

{% step %}

### Allow remote management

Add the account to the Remote Management Users group on the CA host and allow remote PowerShell sessions.
{% endstep %}

{% step %}

### Enable the WinRM listener

Use port 5985 for HTTP or 5986 for HTTPS.
{% endstep %}

{% step %}

### Choose Kerberos if NTLM is blocked

Use a UPN username (`user@CONTOSO.COM`). If you use `DOMAIN\user`, set the Kerberos realm explicitly.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter                                | Required | Type    | Default | Description                                                                                |
| ---------------------------------------- | -------- | ------- | ------- | ------------------------------------------------------------------------------------------ |
| IP (`ip`)                                | Yes      | String  |         | IP address or hostname of the Windows host.                                                |
| Port (`port`)                            | No       | Integer | 5985    | WinRM port. 5985 is the HTTP listener, 5986 the HTTPS listener.                            |
| Username (`username`)                    | Yes      | String  |         | Account used to connect. For Kerberos, use UPN format (`user@CONTOSO.COM`).                |
| Password (`password`)                    | Yes      | String  |         | Password of the account.                                                                   |
| Is Secure (`is_secure`)                  | No       | Boolean | False   | Connect over HTTPS. Use it with port 5986.                                                 |
| Auth Type (`auth_type`)                  | No       | String  | NTLM    | One of Basic, Certificate, NTLM, Kerberos, Plaintext, SSL, Credssp.                        |
| Certificate verification (`cert_verify`) | No       | Boolean | True    | Validate the WinRM HTTPS certificate. Applied only when Is Secure is on.                   |
| Kerberos realm (`kerberos_realm`)        | No       | String  |         | Realm in uppercase. Needed when Auth Type is Kerberos and the username is not in UPN form. |
| KDC IP / FQDN (`kdc_ip`)                 | No       | String  |         | Kerberos KDC host. Leave empty to use DNS discovery.                                       |

## Troubleshooting

| Error message           | Cause                                                                   | Fix                                                                                                                   |
| ----------------------- | ----------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| Connection test failed. | Neither the HTTP nor the HTTPS WinRM session ran `whoami` successfully. | Check the port, Is Secure, Auth Type and the account. The account must be allowed to open remote PowerShell sessions. |

## Change history
