Skip to content

Commit dcfbbe5

Browse files
leefine02leefine02
authored andcommitted
1 parent 0c5cb14 commit dcfbbe5

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

RemoteFile.UnitTests/RemoteFile.UnitTests.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0"/>
13-
<PackageReference Include="xunit" Version="2.4.1"/>
12+
<PackageReference Include="BouncyCastle.Cryptography" Version="2.6.2" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
14+
<PackageReference Include="xunit" Version="2.4.1" />
1415
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
1516
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1617
<PrivateAssets>all</PrivateAssets>

RemoteFile/RemoteCertificateStore.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,18 +257,13 @@ internal void AddCertificate(string alias, string certificateEntry, bool overwri
257257
try
258258
{
259259
Pkcs12StoreBuilder storeBuilder = new Pkcs12StoreBuilder();
260-
Pkcs12Store certs = storeBuilder.Build();
260+
Pkcs12Store newEntry = storeBuilder.Build();
261261

262262
byte[] newCertBytes = removeRootCertificate && !string.IsNullOrEmpty(pfxPassword) ?
263263
RemoveRootCertificate(Convert.FromBase64String(certificateEntry), pfxPassword) :
264264
Convert.FromBase64String(certificateEntry);
265265

266-
Pkcs12Store newEntry = storeBuilder.Build();
267-
268-
X509Certificate2 cert = new X509Certificate2(newCertBytes, pfxPassword, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.EphemeralKeySet);
269-
byte[] binaryCert = cert.Export(X509ContentType.Pkcs12, pfxPassword);
270-
271-
using (MemoryStream ms = new MemoryStream(string.IsNullOrEmpty(pfxPassword) ? binaryCert : newCertBytes))
266+
using (MemoryStream ms = new MemoryStream(newCertBytes))
272267
{
273268
newEntry.Load(ms, string.IsNullOrEmpty(pfxPassword) ? new char[0] : pfxPassword.ToCharArray());
274269
}
@@ -295,7 +290,8 @@ internal void AddCertificate(string alias, string certificateEntry, bool overwri
295290

296291
if (string.IsNullOrEmpty(checkAliasExists))
297292
{
298-
Org.BouncyCastle.X509.X509Certificate bcCert = DotNetUtilities.FromX509Certificate(cert);
293+
//Org.BouncyCastle.X509.X509Certificate bcCert = DotNetUtilities.FromX509Certificate(cert);
294+
Org.BouncyCastle.X509.X509Certificate bcCert = new Org.BouncyCastle.X509.X509Certificate(newCertBytes);
299295
X509CertificateEntry bcEntry = new X509CertificateEntry(bcCert);
300296
if (CertificateStore.ContainsAlias(alias))
301297
{

RemoteFile/RemoteFile.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
11+
<PackageReference Include="BouncyCastle.Cryptography" Version="2.6.2" />
1212
<PackageReference Include="CliWrap" Version="3.6.6" />
1313
<PackageReference Include="Keyfactor.Logging" Version="1.1.1" />
1414
<PackageReference Include="Keyfactor.Orchestrators.IOrchestratorJobExtensions" Version="0.7.0" />

0 commit comments

Comments
 (0)