System.Security.Cryptography fails on WASM (#25285)
This commit is contained in:
parent
80662903a2
commit
a73ae505a2
|
|
@ -82,11 +82,10 @@ namespace Microsoft.AspNetCore.Http.Connections.Client
|
|||
// Internal for testing
|
||||
internal static HttpConnectionOptions ShallowCopyHttpConnectionOptions(HttpConnectionOptions options)
|
||||
{
|
||||
return new HttpConnectionOptions
|
||||
var newOptions = new HttpConnectionOptions
|
||||
{
|
||||
HttpMessageHandlerFactory = options.HttpMessageHandlerFactory,
|
||||
Headers = options.Headers,
|
||||
ClientCertificates = options.ClientCertificates,
|
||||
Cookies = options.Cookies,
|
||||
Url = options.Url,
|
||||
Transports = options.Transports,
|
||||
|
|
@ -99,6 +98,14 @@ namespace Microsoft.AspNetCore.Http.Connections.Client
|
|||
DefaultTransferFormat = options.DefaultTransferFormat,
|
||||
WebSocketConfiguration = options.WebSocketConfiguration,
|
||||
};
|
||||
|
||||
// WASM doesn't support Crypto APIs and our setter throws if you try to assign null
|
||||
if (options.ClientCertificates != null)
|
||||
{
|
||||
newOptions.ClientCertificates = options.ClientCertificates;
|
||||
}
|
||||
|
||||
return newOptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ using System.Security.Cryptography.X509Certificates;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Connections;
|
||||
using Microsoft.AspNetCore.Http.Connections.Client.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Http.Connections.Client
|
||||
{
|
||||
|
|
@ -28,7 +29,13 @@ namespace Microsoft.AspNetCore.Http.Connections.Client
|
|||
public HttpConnectionOptions()
|
||||
{
|
||||
_headers = new Dictionary<string, string>();
|
||||
_clientCertificates = new X509CertificateCollection();
|
||||
|
||||
// System.Security.Cryptography isn't supported on WASM currently
|
||||
if (!Utils.IsRunningInBrowser())
|
||||
{
|
||||
_clientCertificates = new X509CertificateCollection();
|
||||
}
|
||||
|
||||
_cookies = new CookieContainer();
|
||||
|
||||
Transports = HttpTransports.All;
|
||||
|
|
|
|||
Loading…
Reference in New Issue