---
product: Chilkat
product_version: 11.7.0
language: csharp
language_label: C#
class: Secrets
license: bundle
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/csSecretsRef.html
---
# Chilkat Secrets — C# — v11.7.0

> Chilkat 11.7.0 · language=csharp · class=Secrets
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/Secrets.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/csharp/guide.md`.

## Purpose

**Manage application secrets through one consistent API.**

`Chilkat.Secrets` provides a unified interface for storing, retrieving, listing, and deleting secrets across local, cloud-based, and in-memory secret stores. It supports string, binary, and JSON secrets, making it useful for passwords, API keys, OAuth credentials, tokens, unlock codes, certificates, and private configuration data.

**Local secure storage**

- Windows Credential Manager
- Apple Keychain

**Cloud secret managers**

- AWS Secrets Manager
- Azure Key Vault
- IBM Cloud Secrets Manager
- Oracle Cloud Secrets
- Doppler Secrets

**Temporary secrets**

Use in-memory secrets when values should exist only for the lifetime of the running process.

**Flexible content types**

Store and retrieve secrets as strings, binary data, or structured JSON.

**Note:** Cloud-based secret managers often require local bootstrap credentials. These can be stored securely in the Windows Credential Manager or Apple Keychain and then used to authenticate to the cloud secret manager.

Start with the [Conceptual Overview](https://www.chilkatsoft.com/chilkat_secrets_api.asp) and [Components of a Secret Name](https://www.chilkatsoft.com/components_of_a_secret_name.asp). For an extended overview, see the [Secrets Class Overview](https://www.chilkatsoft.com/secrets_class_overview.asp).

## Object creation, unlocking and error handling

**Object Creation**

```csharp
Chilkat.Secrets obj = new Chilkat.Secrets();
```

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in C#.

Minimal complete program:

```csharp
// Required once per process. Any string unlocks a 30-day trial; use your purchased code in production.
Chilkat.Global glob = new Chilkat.Global();
if (!glob.UnlockBundle("Anything for 30-day trial"))
{
    Console.WriteLine(glob.LastErrorText);
    return;
}

Chilkat.Secrets secrets = new Chilkat.Secrets();
```

How failure is reported depends on the method's return type and is stated in the note under each method below. In every case the diagnostic text is in the `LastErrorText` property of the object whose method was called.

## Members common to every Chilkat class

Documented once per language in `common-members.md`; listed here so this page is self-contained.

| Property | Signature | Access | Meaning |
|---|---|---|---|
| `DebugLogFilePath` | `public string DebugLogFilePath {get; set; }` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastErrorHtml` | `public string LastErrorHtml {get; }` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `public string LastErrorText {get; }` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `public string LastErrorXml {get; }` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `public bool LastMethodSuccess {get; set; }` | read/write | Indicates the success or failure of the most recent method call: `true` means success, `false` means failure. |
| `VerboseLogging` | `public bool VerboseLogging {get; set; }` | read/write | If set to `true`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `public string Version {get; }` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `AutoSplit` | property, read/write | `public bool AutoSplit {get; set; }` |
| `Compression` | property, read/write | `public bool Compression {get; set; }` |
| `Location` | property, read/write | `public string Location {get; set; }` |
| `UncommonOptions` | property, read/write | `public string UncommonOptions {get; set; }` |
| `DeleteSecret` | method | `public bool DeleteSecret(JsonObject jsonId);` |
| `GetSecretBd` | method | `public bool GetSecretBd(JsonObject jsonId, BinData bd);` |
| `GetSecretJson` | method | `public bool GetSecretJson(JsonObject jsonId, JsonObject jsonOut);` |
| `GetSecretSb` | method | `public bool GetSecretSb(JsonObject jsonId, StringBuilder sb);` |
| `GetSecretStr` | method | `public string GetSecretStr(JsonObject jsonId);` |
| `ListSecrets` | method | `public bool ListSecrets(JsonObject json, JsonObject jsonOut);` |
| `SecretSpecToJson` | method | `public bool SecretSpecToJson(string secretSpec, JsonObject json);` |
| `SetBootstrapSecret` | method | `public bool SetBootstrapSecret(JsonObject jsonId, Secrets secretContent);` |
| `UpdateSecretBd` | method | `public bool UpdateSecretBd(JsonObject jsonId, BinData secret);` |
| `UpdateSecretJson` | method | `public bool UpdateSecretJson(JsonObject jsonId, JsonObject secret);` |
| `UpdateSecretSb` | method | `public bool UpdateSecretSb(JsonObject jsonId, StringBuilder sb);` |
| `UpdateSecretStr` | method | `public bool UpdateSecretStr(JsonObject jsonId, string secret);` |

## Properties

### Secrets.AutoSplit

`Chilkat 11.7.0 · csharp · Secrets · AutoSplit · property · read/write · since 10.1.0`

```csharp
public bool AutoSplit {get; set; }
```

The AutoSplit property is specific to `local_manager` secrets on Windows. The Windows Credentials Manager supports a maximum of 2560 bytes per secret. If a secret exceeds this size, it will be automatically compressed and split when created or updated, and automatically recomposed when retrieved.

A secret can be split into a maximum of 10 parts.

The default value is `true`.

### Secrets.Compression

`Chilkat 11.7.0 · csharp · Secrets · Compression · property · read/write · since 10.1.0`

```csharp
public bool Compression {get; set; }
```

If set to `true`, then the contents of the secret will be stored compressed. The default value of this property is `false`.

### Secrets.Location

`Chilkat 11.7.0 · csharp · Secrets · Location · property · read/write · since 10.1.0`

```csharp
public string Location {get; set; }
```

The location of the secrets. Possible values are:

- `local_manager` - On Windows this is the Credentials Manager. On MacOS and iOS it is the Keychain. This is not yet an option on Linux or Android.
- `aws_secrets_manager` - AWS Secrets Manager
- `azure_key_vault` - Azure Key Vault
- `ibm_cloud` - IBM Cloud Secrets Manager
- `oracle_cloud` - Oracle Cloud Secrets
- `doppler` - Doppler Secrets
- `memory` - In-Memory Secrets

The default location is the `local_manager`. On Linux and Android, `local_manager` will behave the same as `memory`.

### Secrets.UncommonOptions

`Chilkat 11.7.0 · csharp · Secrets · UncommonOptions · property · read/write · since 10.1.0`

```csharp
public string UncommonOptions {get; set; }
```

This is a catch-all property to be used for uncommon needs. This property defaults to the empty string and should typically remain empty.

## Methods

### Secrets.DeleteSecret

`Chilkat 11.7.0 · csharp · Secrets · DeleteSecret · method · since 10.1.0`

```csharp
public bool DeleteSecret(JsonObject jsonId);
```

Deletes a secret. Cloud secrets managers will typically disable the secret and schedule the secret for deletion after some number of days.

Returns true for success, false for failure.

Async variant: `DeleteSecretAsync` — same arguments, returns a `Task` (see Async variants below).

### Secrets.GetSecretBd

`Chilkat 11.7.0 · csharp · Secrets · GetSecretBd · method · since 10.1.0`

```csharp
public bool GetSecretBd(JsonObject jsonId, BinData bd);
```

Fetches a binary secret and returns the content in `bd`.

Returns true for success, false for failure.

Async variant: `GetSecretBdAsync` — same arguments, returns a `Task` (see Async variants below).

### Secrets.GetSecretJson

`Chilkat 11.7.0 · csharp · Secrets · GetSecretJson · method · since 10.1.0`

```csharp
public bool GetSecretJson(JsonObject jsonId, JsonObject jsonOut);
```

Fetches a JSON secret and returns the content in `jsonOut`.

Returns true for success, false for failure.

Async variant: `GetSecretJsonAsync` — same arguments, returns a `Task` (see Async variants below).

### Secrets.GetSecretSb

`Chilkat 11.7.0 · csharp · Secrets · GetSecretSb · method · since 10.1.0`

```csharp
public bool GetSecretSb(JsonObject jsonId, StringBuilder sb);
```

Fetches a string secret and returns the content in `sb`.

Returns true for success, false for failure.

Async variant: `GetSecretSbAsync` — same arguments, returns a `Task` (see Async variants below).

### Secrets.GetSecretStr

`Chilkat 11.7.0 · csharp · Secrets · GetSecretStr · method · since 10.1.0`

```csharp
public string GetSecretStr(JsonObject jsonId);
```

Fetches a string secret and returns the content of the secret.

Returns `null` on failure

Async variant: `GetSecretStrAsync` — same arguments, returns a `Task` (see Async variants below).

### Secrets.ListSecrets

`Chilkat 11.7.0 · csharp · Secrets · ListSecrets · method · since 10.1.0`

```csharp
public bool ListSecrets(JsonObject json, JsonObject jsonOut);
```

Lists secrets matching the wildcarded or exact values passed in `json`. The results of the query are returned in `jsonOut`.

Returns true for success, false for failure.

Async variant: `ListSecretsAsync` — same arguments, returns a `Task` (see Async variants below).

### Secrets.SecretSpecToJson

`Chilkat 11.7.0 · csharp · Secrets · SecretSpecToJson · method · since 11.5.0`

```csharp
public bool SecretSpecToJson(string secretSpec, JsonObject json);
```

Converts a secret specification string (`secretSpec`) to JSON. A secret specification string is formatted as "!!part1\|part2\|part3\|part4" where parts 3 and 4 are optional. `json` is the output argument.

Returns true for success, false for failure.

### Secrets.SetBootstrapSecret

`Chilkat 11.7.0 · csharp · Secrets · SetBootstrapSecret · method · since 10.1.0`

```csharp
public bool SetBootstrapSecret(JsonObject jsonId, Secrets secretContent);
```

Accessing a cloud-based secrets manager requires authentication credentials, which cannot be stored in the manager itself. Instead, they must be securely stored locally.

One solution is to store the authentication credentials as a secret in the Windows Credentials Manager or Apple Keychain. These credentials serve as the `bootstrap secret` for authenticating with the cloud-based secrets manager.

`jsonId` contains the name of the bootstrap secret. `secretContent` contains the bootstrap's secret content.

Returns true for success, false for failure.

### Secrets.UpdateSecretBd

`Chilkat 11.7.0 · csharp · Secrets · UpdateSecretBd · method · since 10.1.0`

```csharp
public bool UpdateSecretBd(JsonObject jsonId, BinData secret);
```

Creates a binary secret if it does not yet exist, or updates an existing secret. The name of the secret is specified in `jsonId`, and the binary content of the secret in `secret`.

Returns true for success, false for failure.

Async variant: `UpdateSecretBdAsync` — same arguments, returns a `Task` (see Async variants below).

### Secrets.UpdateSecretJson

`Chilkat 11.7.0 · csharp · Secrets · UpdateSecretJson · method · since 10.1.0`

```csharp
public bool UpdateSecretJson(JsonObject jsonId, JsonObject secret);
```

Creates a JSON secret if it does not yet exist, or updates an existing secret. The name of the secret is specified in `jsonId`, and the JSON content of the secret in `secret`.

Returns true for success, false for failure.

Async variant: `UpdateSecretJsonAsync` — same arguments, returns a `Task` (see Async variants below).

### Secrets.UpdateSecretSb

`Chilkat 11.7.0 · csharp · Secrets · UpdateSecretSb · method · since 10.1.0`

```csharp
public bool UpdateSecretSb(JsonObject jsonId, StringBuilder sb);
```

Creates a string secret if it does not yet exist, or updates an existing secret. The name of the secret is specified in `jsonId`, and the string content of the secret in `sb`.

Returns true for success, false for failure.

Async variant: `UpdateSecretSbAsync` — same arguments, returns a `Task` (see Async variants below).

### Secrets.UpdateSecretStr

`Chilkat 11.7.0 · csharp · Secrets · UpdateSecretStr · method · since 10.1.0`

```csharp
public bool UpdateSecretStr(JsonObject jsonId, string secret);
```

Creates a string secret if it does not yet exist, or updates an existing secret. The name of the secret is specified in `jsonId`, and the string content of the secret in `secret`.

Note: Starting in Chilkat **v11.3.0**, if the `service` = `"Chilkat"` and the `username` = `"unlock_code"`, then the secret (which is the Chilkat unlock code) can be stored and retrieved without Chilkat being unlocked. This allows for the Chilkat unlock code itself to be persisted to a secrets manager.

Returns true for success, false for failure.

Async variant: `UpdateSecretStrAsync` — same arguments, returns a `Task` (see Async variants below).

## Events and callbacks

### Secrets.AbortCheck (event)

`Chilkat 11.7.0 · csharp · Secrets · AbortCheck · event`

```csharp
public event AbortCheckEventHandler OnAbortCheck;
```

Enables a method call to be aborted by triggering the AbortCheck event at intervals defined by the `HeartbeatMs` property. If HeartbeatMs is set to its default value of 0, no events will occur. For instance, set HeartbeatMs to 200 to trigger 5 AbortCheck events per second.

### Chilkat .NET Framework Event Implementation

Args are passed using Chilkat.AbortCheckEventArgs

**Event callback implementation:**

```csharp
private void secrets_OnAbortCheck(object sender, Chilkat.AbortCheckEventArgs args)
	{
	    // application code goes here.
	}
```

**To add an event handler:**

```csharp
Chilkat.Secrets secrets = new Chilkat.Secrets();
secrets.OnAbortCheck += secrets_OnAbortCheck;
```

### Chilkat .NET Core Event Implementation

**Event callback implementation:**

```csharp
public void handleAbortCheck(out bool abort)
	{
	    // application code goes here.
	}
```

**To add an event handler:**

```csharp
Chilkat.Secrets secrets = new Chilkat.Secrets();
// ...
Chilkat.Secrets.AbortCheck abortCheck = new Chilkat.Secrets.AbortCheck(handleAbortCheck);
secrets.setAbortCheckCb(abortCheck);
```

### Secrets.PercentDone (event)

`Chilkat 11.7.0 · csharp · Secrets · PercentDone · event`

```csharp
public event PercentDoneEventHandler OnPercentDone;
```

This provides the percentage completion for any method involving network communications or time-consuming processing, assuming the progress can be measured as a percentage. This event is triggered only when it's possible and logical to express the operation's progress as a percentage. The `pctDone` argument will range from 1 to 100. For methods that finish quickly, the number of PercentDone callbacks may vary, but the final callback will have `pctDone` equal to 100. For longer operations, callbacks will not exceed one per percentage point (e.g., 1, 2, 3, ..., 98, 99, 100).

The PercentDone callback also acts as an `AbortCheck` event. For fast methods where PercentDone fires, an AbortCheck event may not trigger since the PercentDone callback already provides an opportunity to abort. For longer operations, where time between PercentDone callbacks is extended, AbortCheck callbacks enable more responsive operation termination.

To abort the operation, set the `abort` output argument to `true`. This will cause the method to terminate and return a failure status or corresponding failure value.

### Chilkat .NET Framework Event Implementation

Args are passed using Chilkat.PercentDoneEventArgs

**Event callback implementation:**

```csharp
private void secrets_OnPercentDone(object sender, Chilkat.PercentDoneEventArgs args)
	{
	    // application code goes here.
	}
```

**To add an event handler:**

```csharp
Chilkat.Secrets secrets = new Chilkat.Secrets();
secrets.OnPercentDone += secrets_OnPercentDone;
```

### Chilkat .NET Core Event Implementation

**Event callback implementation:**

```csharp
public void handlePercentDone(int pctDone, out bool abort)
	{
	    // application code goes here.
	}
```

**To add an event handler:**

```csharp
Chilkat.Secrets secrets = new Chilkat.Secrets();
// ...
Chilkat.Secrets.PercentDone percentDone = new Chilkat.Secrets.PercentDone(handlePercentDone);
secrets.setPercentDoneCb(percentDone);
```

### Secrets.ProgressInfo (event)

`Chilkat 11.7.0 · csharp · Secrets · ProgressInfo · event`

```csharp
public event ProgressInfoEventHandler OnProgressInfo;
```

This event callback provides `tag name`/value pairs that detail what occurs during a method call. To discover existing tag names, create code to handle the event, emit the pairs, and review them. Most tag names are self-explanatory.

Note: Some Chilkat methods don't fire any ProgressInfo events.

### Chilkat .NET Framework Event Implementation

Args are passed using Chilkat.ProgressInfoEventArgs

**Event callback implementation:**

```csharp
private void secrets_OnProgressInfo(object sender, Chilkat.ProgressInfoEventArgs args)
	{
	    // application code goes here.
	}
```

**To add an event handler:**

```csharp
Chilkat.Secrets secrets = new Chilkat.Secrets();
secrets.OnProgressInfo += secrets_OnProgressInfo;
```

### Chilkat .NET Core Event Implementation

**Event callback implementation:**

```csharp
public void handleProgressInfo(string name, string value)
	{
	    // application code goes here.
	}
```

**To add an event handler:**

```csharp
Chilkat.Secrets secrets = new Chilkat.Secrets();
// ...
Chilkat.Secrets.ProgressInfo progressInfo = new Chilkat.Secrets.ProgressInfo(handleProgressInfo);
secrets.setProgressInfoCb(progressInfo);
```

### Secrets.TaskCompleted (event)

`Chilkat 11.7.0 · csharp · Secrets · TaskCompleted · event`

```csharp
public event TaskCompletedEventHandler OnTaskCompleted;
```

Called from the background thread when an asynchronous task completes.

### Chilkat .NET Framework Event Implementation

Args are passed using Chilkat.TaskCompletedEventArgs

**Event callback implementation:**

```csharp
private void secrets_OnTaskCompleted(object sender, Chilkat.TaskCompletedEventArgs args)
	{
	    // application code goes here.
	}
```

**To add an event handler:**

```csharp
Chilkat.Secrets secrets = new Chilkat.Secrets();
secrets.OnTaskCompleted += secrets_OnTaskCompleted;
```

### Chilkat .NET Core Event Implementation

**Event callback implementation:**

```csharp
public void handleTaskIdCompleted(int taskId)
	{
	    // application code goes here.
	}
```

**To add an event handler:**

```csharp
Chilkat.Secrets secrets = new Chilkat.Secrets();
// ...
Chilkat.Secrets.TaskIdCompleted taskIdCompleted = new Chilkat.Secrets.TaskIdCompleted(handleTaskIdCompleted);
secrets.setTaskIdCompletedCb(taskIdCompleted);
```

## Async variants

Each returns a `Task` instead of the result and takes the same arguments as the synchronous method; run the task, wait for `Finished`, then read the result from the task. No new Async methods are added from 11.7.0 on.

```csharp
public Task DeleteSecretAsync(JsonObject jsonId);
public Task GetSecretBdAsync(JsonObject jsonId, BinData bd);
public Task GetSecretJsonAsync(JsonObject jsonId, JsonObject jsonOut);
public Task GetSecretSbAsync(JsonObject jsonId, StringBuilder sb);
public Task GetSecretStrAsync(JsonObject jsonId);
public Task ListSecretsAsync(JsonObject json, JsonObject jsonOut);
public Task UpdateSecretBdAsync(JsonObject jsonId, BinData secret);
public Task UpdateSecretJsonAsync(JsonObject jsonId, JsonObject secret);
public Task UpdateSecretSbAsync(JsonObject jsonId, StringBuilder sb);
public Task UpdateSecretStrAsync(JsonObject jsonId, string secret);
```

## Related classes

[`BinData`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/csharp/classes/BinData.md), [`JsonObject`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/csharp/classes/JsonObject.md), [`StringBuilder`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/csharp/classes/StringBuilder.md)

