Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let PfxBuilder support setting the Cert Algorithm of PFX #323

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Certes/Pkcs/PfxBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.IO;
using System.Linq;
using Certes.Crypto;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Pkcs;
using Org.BouncyCastle.Pkix;
Expand Down Expand Up @@ -70,11 +71,14 @@ public PfxBuilder(byte[] certificate, IKey privateKey)
/// </summary>
/// <param name="friendlyName">The friendly name.</param>
/// <param name="password">The password.</param>
/// <param name="certAlgorithm">The Cert Algorithm</param>
/// <returns>The PFX data.</returns>
public byte[] Build(string friendlyName, string password)
public byte[] Build(string friendlyName, string password, DerObjectIdentifier certAlgorithm = null)
{
var keyPair = LoadKeyPair();
var store = new Pkcs12StoreBuilder().Build();
var builder = new Pkcs12StoreBuilder();
if(certAlgorithm!=null) builder.SetCertAlgorithm(certAlgorithm);
var store = builder.Build();

var entry = new X509CertificateEntry(certificate);
store.SetCertificateEntry(friendlyName, entry);
Expand Down
Loading