OneIdentity.SafeguardDotNet 9.1.0

dotnet add package OneIdentity.SafeguardDotNet --version 9.1.0
                    
NuGet\Install-Package OneIdentity.SafeguardDotNet -Version 9.1.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="OneIdentity.SafeguardDotNet" Version="9.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OneIdentity.SafeguardDotNet" Version="9.1.0" />
                    
Directory.Packages.props
<PackageReference Include="OneIdentity.SafeguardDotNet" />
                    
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 OneIdentity.SafeguardDotNet --version 9.1.0
                    
#r "nuget: OneIdentity.SafeguardDotNet, 9.1.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 OneIdentity.SafeguardDotNet@9.1.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=OneIdentity.SafeguardDotNet&version=9.1.0
                    
Install as a Cake Addin
#tool nuget:?package=OneIdentity.SafeguardDotNet&version=9.1.0
                    
Install as a Cake Tool

SafeguardDotNet

One Identity Safeguard Web API .NET SDK

Overview

SafeguardDotNet provides a comprehensive .NET SDK for interacting with the One Identity Safeguard for Privileged Passwords API. This library simplifies authentication, API calls, and event handling, allowing you to integrate Safeguard functionality into your .NET applications with minimal code.

Key Features

  • Multiple Authentication Methods

    • Username/Password authentication
    • Client certificate authentication (PFX/PEM or certificate store)
    • API token authentication
    • Anonymous access for public endpoints
  • Full API Coverage

    • Access all Safeguard services (Core, Appliance, A2A, Notification)
    • Support for v3 and v4 APIs (v4 is default)
    • Simple method invocation with InvokeMethod()
  • A2A (Application-to-Application) Support

    • Certificate-based password retrieval for automated integrations
    • Access request brokering on behalf of users
    • No manual approval workflow required for configured A2A registrations
  • Real-Time Event Notifications

    • Subscribe to Safeguard events via SignalR
    • Persistent event listeners with auto-reconnect capabilities
    • Role-based notifications for assets, accounts, access requests, and more
  • Production-Ready Features

    • Automatic token refresh for long-running connections
    • Built-in logging via Serilog integration
    • Comprehensive error handling with SafeguardDotNetException
  • Modern Serialization (v9.0+)

    • System.Text.Json with source-generated serializers
    • Trim- and Native-AOT-friendly: usable from PublishAot=true consumers
    • Reduced dependency footprint — no Newtonsoft.Json, no RestSharp, no Microsoft.AspNet.WebApi.Client

Quick Start

Installation

dotnet add package OneIdentity.SafeguardDotNet

Basic Usage

using OneIdentity.SafeguardDotNet;
using System.Security;

// Connect with username/password
SecureString password = GetPasswordSecurely();
var connection = Safeguard.Connect("safeguard.company.com", "local", "Admin", password);

// Call the API
string userData = connection.InvokeMethod(Service.Core, Method.Get, "Me");
Console.WriteLine(userData);

Certificate Authentication

// Using certificate thumbprint from store
var connection = Safeguard.Connect("safeguard.company.com", "756766BB590D7FA9CA9E1971A4AE41BB9CEC82F1");

// Using PFX file
SecureString certPassword = GetPasswordSecurely();
var connection = Safeguard.Connect("safeguard.company.com", @"C:\certs\client.pfx", certPassword);

A2A Password Retrieval

// Get A2A context with certificate
var a2aContext = Safeguard.A2A.GetContext("safeguard.company.com", @"C:\certs\a2a.pfx", certPassword, apiKey);

// Retrieve password
var password = a2aContext.RetrievePassword();

Event Notifications

// Create persistent event listener (auto-reconnects)
var listener = connection.GetPersistentEventListener();

listener.RegisterEventHandler("AssetAccountPasswordUpdated", (eventName, eventBody) => {
    Console.WriteLine($"Password changed: {eventBody}");
});

listener.Start();

API Versions

SafeguardDotNet defaults to the v4 API. To use v3:

var connection = Safeguard.Connect("safeguard.company.com", "local", "Admin", password, apiVersion: 3);

Safeguard 7.X+ hosts both v3 and v4 APIs simultaneously.

Target Framework

  • netstandard2.0 — runs on .NET Framework 4.6.1+, .NET Core 2.0+, .NET 5/6/8/10+
  • Annotated for trimming and Native AOT so consumers publishing with PublishTrimmed=true or PublishAot=true get a clean build with no IL2026 / IL3050 warnings from the SDK

Upgrading to 9.0

Version 9.0 replaces Newtonsoft.Json with System.Text.Json throughout the SDK. Most callers are unaffected, but a few public surface changes are source-breaking:

  • A2ARegistration.Id is now int (was string) to match the API contract.
  • Safeguard.PostLoginResponseAsync now returns string instead of Newtonsoft.Json.Linq.JObject. This is an rSTS plumbing helper used internally by the login modules — most consumers go through Safeguard.Connect(...) or ExchangeRstsTokenForConnectionAsync and are unaffected. Direct callers can parse the response with JsonDocument.Parse(...) or a typed deserialization of their choice.
  • Newtonsoft.Json and Microsoft.AspNet.WebApi.Client are no longer transitive dependencies — if your project relied on them implicitly, add an explicit PackageReference.

Bug fixes shipped alongside the migration:

  • UtcDateTimeJsonConverter now returns DateTime values in UTC.
  • CustomTimeSpanJsonConverter correctly parses the appliance's D:H:M TimeSpan format.

TLS Versions

Starting with version 9.1, SafeguardDotNet no longer hard-pins TLS 1.2. By default the connection lets the operating system negotiate the best mutually supported protocol, which means TLS 1.3 is used automatically when both the client OS and the appliance support it (Safeguard for Privileged Passwords 9.0 and later). Connections continue to use HTTP/1.1.

If you need to constrain the negotiated protocol, every Connect, A2A.GetContext, and login-module entry point accepts optional minTlsVersion / maxTlsVersion parameters. Leave them null (the default) to negotiate, or pin a bound to enforce a policy:

// Negotiate the best protocol (default; enables TLS 1.3 where available)
var connection = Safeguard.Connect("safeguard.company.com", "local", "Admin", password);

// Require TLS 1.3 or newer
var strict = Safeguard.Connect("safeguard.company.com", "local", "Admin", password,
    minTlsVersion: SafeguardTlsVersion.Tls13);

// Pin to exactly TLS 1.2 (e.g. to talk to an older appliance)
var legacy = Safeguard.Connect("safeguard.company.com", "local", "Admin", password,
    minTlsVersion: SafeguardTlsVersion.Tls12, maxTlsVersion: SafeguardTlsVersion.Tls12);

The same minTlsVersion / maxTlsVersion parameters flow through event listeners and the A2A SignalR connections, so the enforced protocol is applied consistently. Supplying a minTlsVersion that is newer than maxTlsVersion throws an ArgumentException.

Certificate and A2A authentication work over TLS 1.3 with no special configuration. Some Safeguard SDKs require connecting through a dedicated SNI hostname to perform client-certificate authentication over TLS 1.3, because their TLS stacks cannot do post-handshake authentication (PHA); SafeguardDotNet does not need that workaround, because .NET performs PHA correctly.

Documentation

Support

This project is supported through:

License

Licensed under Apache 2.0

Copyright (c) 2026 One Identity LLC. All rights reserved.

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 (3)

Showing the top 3 NuGet packages that depend on OneIdentity.SafeguardDotNet:

Package Downloads
OneIdentity.SafeguardDotNet.BrowserLogin

Browser Login for One Identity Safeguard Web API .NET SDK

OneIdentity.SafeguardDotNet.PkceNoninteractiveLogin

PKCE Non-interactive Login for One Identity Safeguard Web API .NET SDK

OneIdentity.SafeguardDotNet.DeviceCodeLogin

Device Code Login for One Identity Safeguard Web API .NET SDK

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.1.0 131 9/5/2026
9.1.0-pre58998 129 9/5/2026
9.0.1 3,864 7/1/2026
9.0.1-pre54686 180 8/13/2026
9.0.1-pre44965 238 7/1/2026
9.0.0-pre40762 367 6/8/2026
9.0.0-pre40181 245 6/4/2026
9.0.0-pre40008 243 6/4/2026
9.0.0-pre39983 242 6/3/2026
9.0.0-pre39666 236 6/3/2026
9.0.0-pre39649 237 6/3/2026
8.3.1 3,021 6/3/2026
8.3.1-pre39597 240 6/2/2026
8.3.0 264 6/2/2026
8.3.0-pre39380 236 6/2/2026
8.3.0-pre38787 251 5/29/2026
8.2.4 228 5/28/2026
8.2.4-pre38438 202 5/27/2026
8.2.3-pre37443 199 5/21/2026
8.2.3-pre36303 203 5/16/2026
Loading failed

One Identity Safeguard Web API .NET SDK

Provides an easy way to connect to Safeguard and call the Safeguard API.
- Password and client certificate authentication
- A2A API support, including access request broker
- Real-time event notifications
- Persistent event listeners that reconnect even after an appliance goes offline

v9.1.0:
- Added TLS 1.3 support: connections negotiate the best mutually supported protocol (TLS 1.3 against SPP 9.0 and later) instead of hard-pinning TLS 1.2
- Added optional minTlsVersion/maxTlsVersion enforcement across Connect, A2A.GetContext, the login modules, event listeners, and A2A SignalR connections

v9.0.0 Breaking Changes:
- Replaced Newtonsoft.Json with System.Text.Json for all serialization
- Removed Newtonsoft.Json and Microsoft.AspNet.WebApi.Client dependencies
- A2ARegistration.Id changed from string to int to match the API contract
- Login modules PostLoginResponseAsync return type changed from JObject to string

Improvements:
- Source-generated JSON serialization (faster startup, reduced allocations, trim/AOT-friendly)
- Reduced dependency footprint

Bug Fixes:
- Fixed CustomTimeSpanJsonConverter TimeSpan parsing for D:H:M format
- Fixed UtcDateTimeJsonConverter to return UTC DateTimes instead of local time