Skip to content

Commit

Permalink
Merge branch 'devPem'
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbod committed Jan 29, 2020
2 parents 937ddb8 + a7e6ec2 commit e6d9006
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Certificate Manager change log

<a name="2020-01-29"></a>
## 2020-01-29 version 1.0.3
* private key pem exports
* private key import with certificate

<a name="2020-01-27"></a>
## 2020-01-27 version 1.0.2
* Small fixes for RSA certificates KeySize
Expand Down
65 changes: 64 additions & 1 deletion Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Certificate Manager is a package which makes it easy to create certificates (cha
Add the NuGet package to the your project file

```
<PackageReference Include="CertificateManager" Version="1.0.1" />
<PackageReference Include="CertificateManager" Version="1.0.3" />
```

The NuGet packages uses dependency injection to setup. In a console application initialize the package as follows:
Expand Down Expand Up @@ -382,6 +382,69 @@ var deviceVerifyPublicKey = importExportCertificate.ExportCertificatePublicKey(d
var deviceVerifyPublicKeyBytes = deviceVerifyPublicKey.Export(X509ContentType.Cert);
File.WriteAllBytes($"deviceVerify.cer", deviceVerifyPublicKeyBytes);
```

## Exporting Importing PEM

RSA

```csharp
var sp = new ServiceCollection()
.AddCertificateManager()
.BuildServiceProvider();

var ccRsa = sp.GetService<CreateCertificatesRsa>();
var iec = sp.GetService<ImportExportCertificate>();

var rsaCert = ccRsa.CreateDevelopmentCertificate("localhost", 2, 2048);

// export
var publicKeyPem = iec.PemExportPublicKeyCertificate(rsaCert);
var rsaPrivateKeyPem = iec.PemExportRsaPrivateKey(rsaCert);

// import
var roundTripPublicKeyPem = iec.PemImportCertificate(publicKeyPem);
var roundTripRsaPrivateKeyPem = iec.PemImportPrivateKey(rsaPrivateKeyPem);

var roundTripFullCert =
iec.CreateCertificateWithPrivateKey(
roundTripPublicKeyPem,
roundTripRsaPrivateKeyPem,
"1234");

```

ECDsa

```csharp
var sp = new ServiceCollection()
.AddCertificateManager()
.BuildServiceProvider();

var cc = serviceProvider.GetService<CreateCertificatesClientServerAuth>();

var root = cc.NewRootCertificate(
new DistinguishedName { CommonName = "root dev", Country = "IT" },
new ValidityPeriod { ValidFrom = DateTime.UtcNow, ValidTo = DateTime.UtcNow.AddYears(10) },
3, "localhost");
root.FriendlyName = "developement root L1 certificate";

var iec = sp.GetService<ImportExportCertificate>();

// export
var publicKeyPem = iec.PemExportPublicKeyCertificate(root);
var eCDsaPrivateKeyPem = iec.PemExportECPrivateKey(root);

// import
var roundTripPublicKeyPem = iec.PemImportCertificate(publicKeyPem);
var roundTripECPrivateKeyPem = iec.PemImportPrivateKey(eCDsaPrivateKeyPem);

var roundTripFullCert =
iec.CreateCertificateWithPrivateKey(
roundTripPublicKeyPem,
roundTripECPrivateKeyPem,
"1234");

```
## General Certificates, full APIs

### Self signed certificate
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Add the NuGet package to the your project file

```
<PackageReference Include="CertificateManager" Version="1.0.2" />
<PackageReference Include="CertificateManager" Version="1.0.3" />
```

The NuGet packages uses dependency injection to setup. In a console application initialize the package as follows:
Expand Down
4 changes: 2 additions & 2 deletions src/CertificateManager/CertificateManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<Description>Certificate Manager is a package which makes it easy to create certificates (chained and self signed) which can be used to in client server authentication and IoT Devices like Azure IoT Hub
</Description>
<PackageTags>certificate authentication mtls pfx cer pem cert crt</PackageTags>
<PackageReleaseNotes>small fixes for RSA certificates</PackageReleaseNotes>
<PackageReleaseNotes>private key, public certificate pem exports</PackageReleaseNotes>
<Copyright>2020 damienbod</Copyright>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>damienbod</Authors>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit e6d9006

Please sign in to comment.