> For the complete documentation index, see [llms.txt](https://docs.fortifiedid.se/access/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fortifiedid.se/access/configuration-reference/secrets-management.md).

# Secrets management

Externalised secrets

## Introduction

Configuration supports externalisation of secrets (i.e. passwords) eliminating the need for clear-text secrets in configuration files.

Secrets are available using the standard mechanism of [property expansion](/access/configuration-reference/property-expansion.md) using the scope `secrets`:

```
"${secrets.<impl-specific-name>}"
```

{% hint style="warning" %}
By default secrets management is not enabled.
{% endhint %}

## Configuration

Since secrets management is part of the configuration subsystem, it must be configured separately. To allow maximum flexibility, configuration is done using environment variables which can be set in the application start script, injected by container management systems or configured on the application user account, depending on how the system is set up.

Different implementations require different configuration. Which implementation to use is specified using the following environment variable:

<pre><code># Default (noop)
FORTIFIED_SECRETS_IMPL=default

# Use built-in 'local' impl
FORTIFIED_SECRETS_IMPL=local

<strong># Use custom impl
</strong>FORTIFIED_SECRETS_IMPL=fully.qualified.class.Name
</code></pre>

## Implementations

### Local

The built-in local secrets management implementation provides decryption of secrets stored in configuration.

Secrets must be encrypted, Base64-encoded, and added to configuration manually. No automatic encryption is done since configuration is read-only.

Only AES encryption (key size 128/256) is supported.

An encrypted property has the following format (where `"yR3v4....wgkR0="` is the Base64-encoded encrypted value):

```json
"${secrets.yR3v4eyaB/L4lTtI1PgPetsuJmafmgBuSYjU904aXMwgkR0=}"
```

To enable this implementation, set the following environment variable(s):

```
# Enable built-in 'local' impl
FORTIFIED_SECRETS_IMPL=local

# AES secret
FORTIFIED_SECRETS_SECRET=my-secret

# AES keysize (optional, defaults to 128)
FORTIFIED_SECRETS_KEY_SIZE=256
```

For more information on how to encrypt secrets for use with this implementation, see: <https://docs.fortifiedid.se/use-cases/misc/encrypt-configuration-secrets>

### OpenSSL

To decrypt a secret encrypted with OpenSSL, use the following configuration:

```
# Enable OpenSSL impl
FORTIFIED_SECRETS_IMPL=fortified.platform.config.secrets.OpenSSLSecretsScope

# AES secret
FORTIFIED_SECRETS_SECRET=my-secret

```

{% hint style="warning" %}
In the current version only `aes-256-cbc` cipher with `sha256` digest is supported.
{% endhint %}

### Custom

It is possible to supply custom secrets management implementations.

Custom implementations are enabled by supplying the fully qualified class name of the implementation.

<pre><code><strong># Use custom impl
</strong>FORTIFIED_SECRETS_IMPL=fully.qualified.class.Name
</code></pre>

A custom implementation must implement the following interface available in `platform-config-<version>.jar`.

```java
package fortified.platform.config.secrets;

public interface SecretsResolver {
    String resolve(String key);
}
```

The custom implementation class and all of its dependencies must also be available on the application class path.

## Setting environment variables using power shell

To set variables on Windows using power shell in terminal execute:

```powershell
[Environment]::SetEnvironmentVariable('FORTIFIED_SECRETS_IMPL', 'local', [EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable('FORTIFIED_SECRETS_SECRET', 'Fortified', [EnvironmentVariableTarget]::Machine)

# AES keysize (optional, defaults to 128)
[Environment]::SetEnvironmentVariable('FORTIFIED_SECRETS_KEY_SIZE', '256', [EnvironmentVariableTarget]::Machine)
```

This will set required variables "machine-wide".


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.fortifiedid.se/access/configuration-reference/secrets-management.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
