LocalSecretVault.Client 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package LocalSecretVault.Client --version 0.2.0
                    
NuGet\Install-Package LocalSecretVault.Client -Version 0.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LocalSecretVault.Client" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LocalSecretVault.Client" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="LocalSecretVault.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LocalSecretVault.Client --version 0.2.0
                    
#r "nuget: LocalSecretVault.Client, 0.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LocalSecretVault.Client@0.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LocalSecretVault.Client&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=LocalSecretVault.Client&version=0.2.0
                    
Install as a Cake Tool

LocalSecretVault.Client -- Usage Guide

LocalSecretVault.Client is a NuGet package for reading secrets from a running LocalSecretVault daemon. Add it to any .NET project that needs secrets instead of .env files.

REQUIREMENTS

  • LocalSecretVault daemon must be installed and running on the same machine.
  • The full path of your executable must be listed under Allowed Callers for the vault (configured via the Admin UI).
  • .NET Standard 2.0 compatible -- works with .NET Framework 4.6.1+, .NET Core 2.0+, .NET 5+.

INSTALLATION

Install via NuGet:

dotnet add package LocalSecretVault.Client

Or in your .csproj:

<PackageReference Include="LocalSecretVault.Client" Version="0.1.0" />

MANUAL DLL REFERENCE (without NuGet)

If you cannot use NuGet, add a direct reference in your .csproj:

<ItemGroup>
  <Reference Include="LocalSecretVault.Client">
    <HintPath>path\to\LocalSecretVault.Client.dll</HintPath>
  </Reference>
</ItemGroup>

And add System.Text.Json if not already present:

dotnet add package System.Text.Json

BASIC USAGE

using LocalSecretVault;
using System.Collections.Generic;

// Open the vault and read all secrets in one call.
// The daemon verifies that this executable's path is in Allowed Callers.
Dictionary<string, string> secrets = LocalSecretVaultManager.Open("my-vault");

string baseUrl  = secrets["API_BASE_URL"];
string clientId = secrets["API_CLIENT_ID"];
string secret   = secrets["API_CLIENT_SECRET"];

// Use immediately -- do not store 'secrets' in a static field or log its contents.

USAGE WITH Microsoft.Extensions.Configuration

The recommended pattern is to load secrets at startup directly into your configuration builder, then let the dictionary go out of scope:

using LocalSecretVault;
using Microsoft.Extensions.Configuration;

var builder = new ConfigurationBuilder()
    .AddJsonFile("appsettings.json", optional: false);

var secrets = LocalSecretVaultManager.Open("my-vault");
builder.AddInMemoryCollection(secrets);

IConfiguration config = builder.Build();

string baseUrl = config["API_BASE_URL"];

USAGE WITH IHostBuilder / Generic Host (.NET 6+)

using LocalSecretVault;
using Microsoft.Extensions.Hosting;

var host = Host.CreateApplicationBuilder(args);

var secrets = LocalSecretVaultManager.Open("my-vault");
host.Configuration.AddInMemoryCollection(secrets);

// IConfiguration, IOptions<T>, etc. all see the vault values
host.Services.Configure<MyOptions>(host.Configuration.GetSection("MySection"));

await host.Build().RunAsync();

USAGE WITH ASP.NET Core (Program.cs / WebApplication)

using LocalSecretVault;

var builder = WebApplication.CreateBuilder(args);

var secrets = LocalSecretVaultManager.Open("my-vault");
builder.Configuration.AddInMemoryCollection(secrets);

builder.Services.AddControllers();
// ... rest of setup

var app = builder.Build();
app.MapControllers();
app.Run();

ERROR HANDLING

All exceptions derive from LocalSecretVaultException.

using LocalSecretVault;

try
{
    var secrets = LocalSecretVaultManager.Open("my-vault");
    // use secrets...
}
catch (VaultConnectionException ex)
{
    // Daemon not running, pipe not found, or connection timed out.
    // Appropriate to retry with backoff, or fail fast at startup.
    Console.Error.WriteLine($"Vault service unavailable: {ex.Message}");
    throw;
}
catch (VaultAccessDeniedException ex)
{
    // This executable's path is not in Allowed Callers for the vault.
    // Fix: open the Admin UI, select the vault, add this exe under Allowed Callers.
    // Retrying will not help -- this is a configuration issue.
    Console.Error.WriteLine($"Access denied: {ex.Message}");
    throw;
}
catch (VaultNotFoundException ex)
{
    // The vault name does not exist. Check spelling or create it in the Admin UI.
    Console.Error.WriteLine($"Vault not found: {ex.VaultName}");
    throw;
}
catch (VaultServiceException ex)
{
    // Unexpected daemon error. Check the service logs at:
    // %LOCALAPPDATA%\LocalSecretVault\logs\daemon-YYYY-MM-DD.log
    Console.Error.WriteLine($"Vault service error: {ex.Message}");
    throw;
}

RETRY WITH BACKOFF (optional)

VaultConnectionException is the only retriable error (e.g. daemon still starting up):

using LocalSecretVault;

static Dictionary<string, string> OpenWithRetry(string vaultName, int maxAttempts = 3)
{
    int delayMs = 500;
    for (int attempt = 1; attempt <= maxAttempts; attempt++)
    {
        try
        {
            return LocalSecretVaultManager.Open(vaultName);
        }
        catch (VaultConnectionException) when (attempt < maxAttempts)
        {
            Thread.Sleep(delayMs);
            delayMs *= 2;
        }
    }
    return LocalSecretVaultManager.Open(vaultName); // final attempt, let exceptions propagate
}

SECURITY NOTES

  • No caching. Every Open() call makes a fresh pipe connection. The library never stores secrets between calls.

  • ZeroMemory. The raw response bytes are zeroed immediately after deserialization.

  • Caller verification. The daemon resolves the calling process's executable path via Win32 QueryFullProcessImageName and compares it against Allowed Callers. Symlinks and junctions in the path are rejected by the daemon.

  • Do not log the dictionary. Structured loggers (Serilog, NLog, etc.) may serialize objects passed to log statements. Never pass the secrets dictionary to any logger.

  • Do not store in static fields. Assign values to your DI container or configuration builder and let the dictionary go out of scope immediately.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.4.0 91 5/18/2026
0.3.1 96 5/18/2026
0.3.0 99 5/18/2026
0.2.0 95 5/15/2026
0.1.0 93 5/13/2026