This is the home of the X509Crypto and EasyPKIView class libraries.
X509Crypto is a class library which can be used to easily encrypt text expressions and files using X509 digital certificates and keys. Whether you have a background in Public Key Encryption or you've never really been exposed to certificates all, my aim with this library is for you to find it very simple to use in any of your .NET Framework projects.
The purpose of the EasyPKIView class library is to simplify working with PKI-related Active Directory objects, including Enrollment Services objects (CAs) and certificate templates.
Latest Stable Releases
News
Date | Story |
---|---|
03-Dec-2020 | Check out our brand new X509Crypto PowerShell module! |
X509Crypto makes it easy to encrypt and recover text expressions in your .NET projects:
1. Install the X509Crypto PowerShell module:
The X509Crypto PowerShell module can be installed from the PowerShell Gallery.
> Install-Module X509Crypto
# ...Or if you are not an admin:
> Install-Module X509Crypto -Scope CurrentUser
2. Use the New-X509Alias cmdlet:
This cmdlet instantiates a new X509Crypto Alias (which stores encrypted secrets). In this example, we don't have a previously-existing certificate and key pair, so we'll execute the cmdlet without the -Thumbprint parameter, which will trigger the creation of a new certificate that will be automatically associated with this X509Alias.
> $Alias = New-X509Alias -Name myvault -Location user
New alias "myvault" committed to "user" X509Context
Thumbprint: B31FE7E7AE5229F8186782742CF579197FA859FD
3. Use the Protect-X509CryptoSecret PowerShell cmdlet to encrypt a secret
In this example, we'll be storing an API authentication key in the X509Alias "myvault". Secrets are stored in X509Aliases as key/value pairs, so we'll assign the identifier "apikey" to this new secret.
> $Alias | Protect-X509CryptoSecret -Id apkikey -Input '80EAF03248965AC2B78090'
Secret "apkikey" added to X509Alias "myvault4" in the user X509Context
3. Reference the secret in your program
Once you have an X509Alias established with your secret(s) added, it is trivial to retreive them in your program with the Org.X509Crypto nuget package installed:
using Org.X509Crypto;
namespace SampleApp
{
class Program
{
static void Main(string[] args)
{
// Instantiate the X509Alias object, referencing the "myvault" alias in the CurrentUser context
using (var Alias = new X509Alias(@"myvault", X509Context.UserReadOnly))
{
// Recover the plaintext secret "apikey" as plaintext in a string variable
string apiKey = Alias.RecoverSecret(@"apikey");
// Use the secret before leaving the "using" block so that it will be garbage-collected promptly
MyApi.Connect(apiKey);
}
}
}
}
Reach out to the project Owner: Mike Bruno with any questions or comments.