OpenSSL.X509Certificate2.Provider 1.0.2

Parses OpenSSL public and private (rsa) key components and returns a X509Certificate2 with RSACryptoServiceProvider.

There is a newer version of this package available.
See the version list below for details.
Install-Package OpenSSL.X509Certificate2.Provider -Version 1.0.2
dotnet add package OpenSSL.X509Certificate2.Provider --version 1.0.2
<PackageReference Include="OpenSSL.X509Certificate2.Provider" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OpenSSL.X509Certificate2.Provider --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

OpenSSL X509Certificate2 Provider

Parses OpenSSL public and private key components and returns a X509Certificate2 with RSA/RSACryptoServiceProvider. (Based on http://www.jensign.com/opensslkey/opensslkey.cs)

| Project | NuGet |
| ------- | ----- |
| OpenSSL.PrivateKeyDecoder | NuGet Badge |
| OpenSSL.X509Certificate2.Provider | NuGet Badge |

Support for the following frameworks:

  • .NET 2.0
  • .NET 3.5
  • .NET 4.5 and up
  • .NET Standard 1.3 (also NET Core 1.1)
  • .NET Standard 2.0 (also NET Core 2.0)

Support for decoding RSA Private Key and Private Key.

Example

Generate public certificate + privatekey

Generate public certificate + privatekey using:

openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout private.key -out certificate_pub.crt

Code example 1 - decode private key

If you just want to decode the private key into a RSACryptoServiceProvider, use the following code:

string privateKeyText = File.ReadAllText("private.key");

IOpenSSLPrivateKeyDecoder decoder = new OpenSSLPrivateKeyDecoder();
RSACryptoServiceProvider cryptoServiceProvider = decoder.Decode(privateKeyText);

// Example: sign the data
byte[] hello = new UTF8Encoding().GetBytes("Hello World");
byte[] hashValue = cryptoServiceProvider.SignData(hello, CryptoConfig.MapNameToOID("SHA256"));

// Example: use the PrivateKey from above for signing a JWT token using Jose.Jwt:
string token = Jose.JWT.Encode(payload, cryptoServiceProvider, JwsAlgorithm.RS256);

Code example 2 - Create a X509 certificate and add private key

string certificateText = File.ReadAllText("certificate_pub.crt");
string privateKeyText = File.ReadAllText("private.key");

ICertificateProvider provider = new CertificateFromFileProvider(certificateText, privateKeyText);
X509Certificate2 certificate = provider.Certificate;

// Example: use the PrivateKey from the certificate above for signing a JWT token using Jose.Jwt:
string token = Jose.JWT.Encode(payload, certificate.PrivateKey, JwsAlgorithm.RS256);

OpenSSL X509Certificate2 Provider

Parses OpenSSL public and private key components and returns a X509Certificate2 with RSA/RSACryptoServiceProvider. (Based on http://www.jensign.com/opensslkey/opensslkey.cs)

| Project | NuGet |
| ------- | ----- |
| OpenSSL.PrivateKeyDecoder | NuGet Badge |
| OpenSSL.X509Certificate2.Provider | NuGet Badge |

Support for the following frameworks:

  • .NET 2.0
  • .NET 3.5
  • .NET 4.5 and up
  • .NET Standard 1.3 (also NET Core 1.1)
  • .NET Standard 2.0 (also NET Core 2.0)

Support for decoding RSA Private Key and Private Key.

Example

Generate public certificate + privatekey

Generate public certificate + privatekey using:

openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout private.key -out certificate_pub.crt

Code example 1 - decode private key

If you just want to decode the private key into a RSACryptoServiceProvider, use the following code:

string privateKeyText = File.ReadAllText("private.key");

IOpenSSLPrivateKeyDecoder decoder = new OpenSSLPrivateKeyDecoder();
RSACryptoServiceProvider cryptoServiceProvider = decoder.Decode(privateKeyText);

// Example: sign the data
byte[] hello = new UTF8Encoding().GetBytes("Hello World");
byte[] hashValue = cryptoServiceProvider.SignData(hello, CryptoConfig.MapNameToOID("SHA256"));

// Example: use the PrivateKey from above for signing a JWT token using Jose.Jwt:
string token = Jose.JWT.Encode(payload, cryptoServiceProvider, JwsAlgorithm.RS256);

Code example 2 - Create a X509 certificate and add private key

string certificateText = File.ReadAllText("certificate_pub.crt");
string privateKeyText = File.ReadAllText("private.key");

ICertificateProvider provider = new CertificateFromFileProvider(certificateText, privateKeyText);
X509Certificate2 certificate = provider.Certificate;

// Example: use the PrivateKey from the certificate above for signing a JWT token using Jose.Jwt:
string token = Jose.JWT.Encode(payload, certificate.PrivateKey, JwsAlgorithm.RS256);

Release Notes

Fixed issue (#3) and added NET Standard 2.0 support.

NuGet packages (54)

Showing the top 5 NuGet packages that depend on OpenSSL.X509Certificate2.Provider:

Package Downloads
Twilio.Api
Twilio API for .NET by CloudRail provides an easy solution to programmatically send SMS messages. Get a free license key at: https://cloudrail.com Platform Supports: Cloudrail SDK is built with Microsoft .NET Standard 2.0 which supports the following - .NET Framework 4.6.1 - .NET Core 2.0 - Mono 5.4
Telegram.Api
Telegram API for .NET by CloudRail provides an instant messaging service and software application in which you can send text, image, videos and files. Get a free license key at: https://cloudrail.com Features: - Send text messages - Send files, images, videos and audios - Parse messages received on your webhook - Download the content of an attachment sent to your webhook - Advance Request: Use any Telegram functionality that is missing from CloudRail Platform Supports: Cloudrail SDK is built with Microsoft .NET Standard 2.0 which supports the following - .NET Framework 4.6.1 - .NET Core 2.0 - Mono 5.4
Gmail.Api
Gmail API for .NET by CloudRail provides an easy solution to send email with attachments. Get a free license key at: https://cloudrail.com Platform Supports: Cloudrail SDK is built with Microsoft .NET Standard 2.0 which supports the following - .NET Framework 4.6.1 - .NET Core 2.0 - Mono 5.4
YouTube.Api
YouTube API for .NET by CloudRail provides an easy solution to search videos, upload videos and many more features. Get a free license key at: https://cloudrail.com Features: - Search for videos - Upload videos - Get a list of videos for a channel - Get channel details - Get your own channel details - Get video details - Advance Request: Use any YouTube functionality that is missing from CloudRail Platform Supports: Cloudrail SDK is built with Microsoft .NET Standard 2.0 which supports the following - .NET Framework 4.6.1 - .NET Core 2.0 - Mono 5.4
CloudRail.SDK
CloudRail SDK is an API integration solution which abstracts multiple APIs from different providers into a single and universal interface. Get a free license key at: https://cloudrail.com Unified API Library: - Cloud Storage: Dropbox, Google Drive, OneDrive, Box, PCloud, OneDrive Business, Egnyte - Business Cloud Storage: Amazon S3, Google Cloud Platform, Microsoft Azure, Rackspace, Backblaze - Social Profiles: Facebook, GitHub, Google+, LinkedIn, Slack, Twitter, Windows Live, Yahoo, Instagram, Heroku - Social Interaction: Facebook, Facebook Page, Twitter - Payment: Paypal, Stripe - Email: SendGrid, Gmail, Malijet - SMS: Nexmo, Twilio, Twizo - Point of Interest: Google Places, Foursquare, Yelp - Video: Youtube, Twitch, Vimeo Platform Supports: Cloudrail SDK is built with Microsoft .NET Standard 2.0 which supports the following - .NET Framework 4.6.1 - .NET Core 2.0 - Mono 5.4

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.3.0 79,929 8/18/2018
1.2.0 42,028 3/7/2018
1.1.0 452 3/3/2018
1.0.2 1,634 10/8/2017
1.0.1 523 7/20/2017
1.0.0 539 7/16/2017