CertiForce 0.0.10

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

CertiForce

A .NET library for secure Salesforce authentication using JWT Bearer Token Flow with private key authentication. This library provides a more secure alternative to username/password authentication by leveraging X.509 certificates for server-to-server authentication.

Features

  • Secure Salesforce authentication using JWT Bearer Token Flow
  • Support for PKCS#1 and PKCS#8 private key formats
  • Async/await support for all operations
  • Extensible architecture with interfaces for custom implementations
  • Built with .NET 8.0

Installation

NuGet Package Manager

Install-Package CertiForce -Version 0.0.18

.NET CLI

dotnet add package CertiForce --version 0.0.18

Prerequisites

  • .NET 8.0 SDK or later
  • A Salesforce Connected App with JWT Bearer Flow enabled
  • A valid X.509 certificate with private key (PKCS#1 or PKCS#8 format)
  • Salesforce User with the necessary permissions

Usage

Basic Usage

using CertUtils;
using CertUtils.Cert;
using CertUtils.Salesforce;
using CertUtils.Token;

// Initialize the providers
var privateKeyProvider = new UrlPrivateKeyProvider("https://your-domain.com/private.key");
var jwtTokenGenerator = new JwtTokenGenerator(
    "your-client-id",
    "your-salesforce-username",
    "https://login.salesforce.com"
);
var tokenRequester = new SalesforceTokenRequester("https://login.salesforce.com");

// Create the token provider
var tokenProvider = new SalesforceTokenProvider(
    privateKeyProvider,
    jwtTokenGenerator,
    tokenRequester
);

// Get the access token
try
{
    string accessToken = await tokenProvider.GetAccessTokenAsync();
    Console.WriteLine($"Access Token: {accessToken}");
}
catch (Exception ex)
{
    Console.WriteLine($"Error: {ex.Message}");
}

Custom Implementations

You can implement the following interfaces to customize the behavior:

  • IPrivateKeyProvider: Provide private key from custom sources
  • IJwtTokenGenerator: Custom JWT token generation
  • ITokenRequester: Custom token request handling

Configuration

Salesforce Connected App Setup

  1. In Salesforce Setup, navigate to App Manager
  2. Create a new Connected App
  3. Enable Use digital signatures and upload your certificate
  4. Enable JWT Bearer Flow
  5. Add the following OAuth scopes:
    • Access and manage your data (api)
    • Perform requests on your behalf at any time (refresh_token, offline_access)

Error Handling

The library throws exceptions for various error conditions. Always wrap token acquisition in try-catch blocks and handle exceptions appropriately.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Acknowledgments

  • Built with ❤️ by Richard Lawidjaja
  • Uses Portable.BouncyCastle for cryptographic operations
  • Inspired by Salesforce's JWT Bearer Token Flow
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
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.0.10 126 5/29/2025
0.0.9 127 5/29/2025