Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.
Merged
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
15 changes: 14 additions & 1 deletion src/Titanium.Web.Proxy/Network/Certificate/BCCertificateMaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Org.BouncyCastle.Security;
using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.X509;
using Titanium.Web.Proxy.Helpers;
using Titanium.Web.Proxy.Shared;
using X509Certificate = Org.BouncyCastle.X509.X509Certificate;

Expand Down Expand Up @@ -166,7 +167,19 @@ private static X509Certificate2 generateCertificate(string hostName,
private static X509Certificate2 withPrivateKey(X509Certificate certificate, AsymmetricKeyParameter privateKey)
{
const string password = "password";
var store = new Pkcs12Store();
Pkcs12Store store = null;

if(RunTime.IsRunningOnMono)
{
Pkcs12StoreBuilder builder = new Pkcs12StoreBuilder();
builder.SetUseDerEncoding(true);
store = builder.Build();
}
else
{
store = new Pkcs12Store();
}

var entry = new X509CertificateEntry(certificate);
store.SetCertificateEntry(certificate.SubjectDN.ToString(), entry);

Expand Down