Skip to content
Managed .NET (C#) utility library for working with PEM files with DER/ASN.1 encoding
C#
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Add DerAsnUtcTime type Oct 16, 2018
tests Add DerAsnUtcTime type Oct 16, 2018
.gitignore Initial code push May 24, 2017
LICENSE Initial code push May 24, 2017
PemUtils.sln Convert project files to VS2017 format + add netstandard1.5 and net45… Jun 27, 2017
README.md Update README.md [skip ci] Mar 8, 2019

README.md

PEM-utils

Build status

Managed .NET (C#) utility library for working with PEM files with DER/ASN.1 encoding.

This project has 2 separate libraries:

  • DerConverter - for converting ASN.1 syntax from/to binary data
  • PemUtils - builds on top of DerConverter for reading/writing RSAParameters from/to a PEM formatted file

PEM files are commonly used to exchange public or private key data.

Currently files with these headers are supported:

  • ----- BEGIN PUBLIC KEY ----- / ----- END PUBLIC KEY -----
  • ----- BEGIN RSA PRIVATE KEY ----- / ----- END RSA PRIVATE KEY -----

Get it on NuGet

PM> Install-Package PemUtils

or if you only want a DER converter:

PM> Install-Package DerConverter

Usage

Reading

using (var stream = File.OpenRead(path))
using (var reader = new PemReader(stream))
{
    var rsaParameters = reader.ReadRsaKey();
    // ...
}

Writing

using (var stream = File.Create(path))
using (var writer = new PemWriter(stream))
{
    // ...
    writer.WritePublicKey(rsaParameters);
}
You can’t perform that action at this time.