1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-06 05:28:15 -05:00

Async GetEmbeddedCertificate

This commit is contained in:
Kyle Spearrin 2020-01-13 15:35:50 -05:00
parent 3f4a4bac2a
commit dda3c3a123
2 changed files with 4 additions and 3 deletions

View File

@ -46,7 +46,8 @@ namespace Bit.Core.Services
"B34876439FCDA2846505B2EFBBA6C4A951313EBE";
if(_globalSettings.SelfHosted)
{
_certificate = CoreHelpers.GetEmbeddedCertificate("licensing.cer", null);
_certificate = CoreHelpers.GetEmbeddedCertificateAsync("licensing.cer", null)
.GetAwaiter().GetResult();
}
else if(CoreHelpers.SettingHasValue(_globalSettings.Storage?.ConnectionString) &&
CoreHelpers.SettingHasValue(_globalSettings.LicenseCertificatePassword))

View File

@ -169,13 +169,13 @@ namespace Bit.Core.Utilities
return new X509Certificate2(file, password);
}
public static X509Certificate2 GetEmbeddedCertificate(string file, string password)
public async static Task<X509Certificate2> GetEmbeddedCertificateAsync(string file, string password)
{
var assembly = typeof(CoreHelpers).GetTypeInfo().Assembly;
using(var s = assembly.GetManifestResourceStream($"Bit.Core.{file}"))
using(var ms = new MemoryStream())
{
s.CopyTo(ms);
await s.CopyToAsync(ms);
return new X509Certificate2(ms.ToArray(), password);
}
}