Skip to content

Commit b943aac

Browse files
committed
Certificate loading
1 parent 0a98952 commit b943aac

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/ServiceControl.RavenDB/RavenClientCertificate.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static class RavenClientCertificate
1515
try
1616
{
1717
var bytes = Convert.FromBase64String(certInfo.ClientCertificateBase64);
18-
return new X509Certificate2(bytes, certInfo.ClientCertificatePassword);
18+
return X509CertificateLoader.LoadPkcs12(bytes, certInfo.ClientCertificatePassword);
1919
}
2020
catch (Exception x) when (x is FormatException or CryptographicException)
2121
{
@@ -29,15 +29,15 @@ public static class RavenClientCertificate
2929
{
3030
throw new Exception("Could not read the RavenDB client certificate from the supplied path because no file was found.");
3131
}
32-
return new X509Certificate2(certInfo.ClientCertificatePath, certInfo.ClientCertificatePassword);
32+
return X509CertificateLoader.LoadPkcs12FromFile(certInfo.ClientCertificatePath, certInfo.ClientCertificatePassword);
3333
}
3434

3535
var applicationDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) ?? string.Empty;
3636
var certificatePath = Path.Combine(applicationDirectory, "raven-client-certificate.pfx");
3737

3838
if (File.Exists(certificatePath))
3939
{
40-
return new X509Certificate2(certificatePath, certInfo.ClientCertificatePassword);
40+
return X509CertificateLoader.LoadPkcs12FromFile(certificatePath, certInfo.ClientCertificatePassword);
4141
}
4242
return null;
4343
}

0 commit comments

Comments
 (0)