---
title: "Protect Agent/Server Communication"
description: "Learn how to protect agent/server communication in Identity Manager with OpenID Connect, encryption certificates, and an OpenIdClient with a hashed secret."
sidebar_position: 30
---

# Protect Agent/Server Communication

This guide shows how to set up a secured authentication system between Identity Manager's agent and server.

## Overview

Identity Manager provides a simple way to protect the communication between agent and server, using OpenID Connect.

First, ensure to understand the OpenID protocol. For example, [see Microsoft's documentation on the matter](https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc).

The idea, when sending data from the agent to the server, is the following:

1. the agent decrypts its own data which was encrypted with the agent-side certificate;
2. the agent calls the server, and sends its HTTPS-encrypted message;
3. the server receives and decrypts the message, before encrypting it again with its own encryption
certificate configured by Identity Manager.

![Schema: Agent/Server Communication](/images/identitymanager/agent-server-communication.webp)

### Configuration details

The server must be configured, in its `appsettings.json`, with:

- an encryption certificate with the private and public keys, to be able to send signed
tokens.

The agent must be configured, in its `appsettings.json`, with:

- an encryption certificate with at least the server's public key, to be able to verify the
tokens sent by the server;
- another encryption certificate meant to encrypt specific files such as logs or temporary files;
- an SSL encryption certificate for the HTTPS connection.

The SSL certificate is required when working in an on-premises environment. In a SaaS environment, Identity Manager provides it.

to give to the agent the right permissions, the XML configuration must specify an [OpenIdClient](../../integrations/toolkit/xml-configuration/access-control/openidclient.md) linked to its hashed secret, and to a Identity Manager profile.

## Protect Agent/Server Communication

Protect agent/server communication by proceeding as follows:

1. ensure that both the agent and server configurations specify an encryption certificate. See
the [Application Settings](../../configuration/network-configuration/agent-configuration/appsettings.md) for additional information.

    > For example:
>
    > ```
>
    > appsettings.json
>
    > {
    >   "IdentityServer": {
    >       "X509KeyFilePath": "./identitymanager.pfx",
    >       "X509KeyFilePassword": "secret"
    >   },
    >   ...
    > }
>
    > ```

2. ensure that the agent is also configured with its own encryption certificate. See the
[Application Settings](../../configuration/network-configuration/agent-configuration/appsettings.md) for additional information.

    > For example:
>
    > ```
>
    > appsettings.json
>
    > {
    >   "EncryptionCertificate": {
    >       "File": "./Usercube-Files.pfx",
    >       "Password": "secret",
    >       "EncryptFile": true
    >   },
    >   ...
    > }
>
    > ```

3. Configure an OpenIdClient, both on agent side in `appsettings.agent.json` with the non-hashed
secret and on server side in the XML configuration with the secret hashed by the [Usercube-New-OpenIDSecret](../../integrations/executables/references/new-openidsecret.md) executable. See the [OpenIdClient](../../integrations/toolkit/xml-configuration/access-control/openidclient.md) for additional information.

    > For example on agent side:
>
    > ```
>
    > appsettings.agent.json
>
    > {
    >   "OpenID": {
    >       "OpenIdClients": {
    >           "Job": "newSecret"
    >       },
    >       ...
    >   }
    >   ...
    > }
>
    > ```
>
    > And on server side:
>
    > ```
>
    > ./Usercube-New-OpenIDSecret.exe
>
    > ```
>
    > `<OpenIdClient Identifier="Job" HashedSecret="OPENID_CLIENT_HASH" DisplayName_L1="Permissions for jobs" Profile="Administrator" />`
>
    > ```
>
    > ```

