Pfx Certificate Library is a .NET tool designed to simplify the creation, management, and installation of self-signed certificates for use in development environments. It provides an easy-to-use API for generating certificates and managing their lifecycle.
- Overview
- Requirements
- Features
- Getting Started
- Usage
- Contributing
- Bug / Issue Reporting
- License
- Contact
- Acknowledgments
- Generate self-signed certificates with customizable properties.
- Export certificates to
.pfxfiles with private keys. - Install certificates into the local certificate store.
- Remove certificates from the store by subject name.
- Fully asynchronous API for modern .NET applications.
To get started with the Form library, you will need to install the library in your .NET project. You can do this using NuGet Package Manager or by adding the package reference directly to your project file.
- .NET 9.0 or later
To use the library, you will need to download and then add a reference to the library in your project. Follow the instructions below to install the library and get started.
You can install the library using the NuGet Package Manager Console. Open the console and run the following command:
Install-Package TirsvadCLI.PfxCertificateManager- Open your project in Visual Studio.
- Right-click on your project in the Solution Explorer and select "Manage NuGet Packages".
- Search for "TirsvadCLI.PfxCertificateManager" in the NuGet Package Manager.
- Click "Install" to add the library to your project.
You can also install the library using the .NET CLI. Open a terminal and run the following command:
dotnet add package TirsvadCLI.PfxCertificateManagerIf you want to clone the repository and build the library from source, you can do so using Git. Make sure you have Git installed on your machine. Then, run the following command in your terminal:
git clone git@github.com:TirsvadCLI/Dotnet.Lib.PfxCertificate.git- Create a Self-Signed Certificate
Use theCreateCertificateAsyncmethod to generate a self-signed certificate and save it as a.pfxfile:await CertificateManager.CreateCertificateAsync( commonName: "MySubject", // Common Name (CN) organization: "MyOrganization", // Organization (O) organizationUnit: "MyOrgUnit", // Organizational Unit (OU) country: "US", // Country (C) state: "MyState", // State (S) locality: "MyLocality", // Locality (L) password: "MyPassword123!" // Password for the .pfx file );
- Add a Certificate to the Store
Use theAddCertificateAsyncmethod to add a.pfxcertificate to a specific certificate store:await CertificateManager.AddCertificateAsync( pfxPath: "MySubject.pfx", // Path to the .pfx file password: "MyPassword123!", // Password for the .pfx file storeName: StoreName.My, // Certificate store name (e.g., My, Root) storeLocation: StoreLocation.CurrentUser // Store location (e.g., CurrentUser, LocalMachine) );
- Remove a Certificate from the Store
Use theRemoveCertificateAsyncmethod to remove a certificate from a specific store by its thumbprint:await CertificateManager.RemoveCertificateAsync( thumbprint: "THUMBPRINT", // Thumbprint of the certificate storeName: StoreName.My, // Certificate store name (e.g., My, Root) storeLocation: StoreLocation.CurrentUser // Store location (e.g., CurrentUser, LocalMachine) );
- Display Certificate Details
TheDisplayCertificateDetailsmethod is used internally to print certificate details to the console. You can use it to inspect certificates:var cert = new X509Certificate2("MySubject.pfx", "MyPassword123!"); CertificateManager.DisplayCertificateDetails(cert);
- The
CreateCertificateAsyncmethod generates a self-signed certificate valid for 5 years by default. - The
AddCertificateAsyncandRemoveCertificateAsyncmethods are only supported on Windows for managing the certificate store. - Ensure you have the necessary permissions to access the certificate store when using
AddCertificateAsyncorRemoveCertificateAsync.
These examples demonstrate how to use the core features of the CertificateManager class. For more advanced usage, refer to the source code or extend the functionality as needed.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature')- Note: Before committing, ensure you have created appropriate tests for your changes. This helps maintain the quality and reliability of the project.
- Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
If you encounter a bug or have an issue to report, please follow these steps:
-
Go to the Issues Page
Navigate to the GitHub Issues page. -
Click "New Issue"
Click the green "New Issue" button to create a new issue. -
Provide Details
- Title: Write a concise and descriptive title for the issue.
- Description: Include the following details:
- Steps to reproduce the issue.
- Expected behavior.
- Actual behavior.
- Environment details (e.g., OS, .NET version, etc.).
- Attachments: Add screenshots, logs, or any other relevant files if applicable.
- Submit the Issue
Once all details are filled in, click "Submit new issue" to report it.
Your feedback is valuable and helps improve the project!
Distributed under the GPL-3.0 License.
Jens Tirsvad Nielsen - LinkedIn
