Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ public async ValueTask<ConnectionContext> ConnectAsync(EndPoint endPoint, Cancel
// 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,
Expand All @@ -99,6 +98,14 @@ internal static HttpConnectionOptions ShallowCopyHttpConnectionOptions(HttpConne
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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Http.Connections.Client.Internal;

namespace Microsoft.AspNetCore.Http.Connections.Client
{
Expand All @@ -28,7 +29,13 @@ public class HttpConnectionOptions
public HttpConnectionOptions()
{
_headers = new Dictionary<string, string>();
_clientCertificates = new X509CertificateCollection();

// System.Security.Cryptography isn't supported on WASM currently
if (!Utils.IsRunningInBrowser())
Copy link
Contributor

@pranavkm pranavkm Aug 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you wanted to be extra nice, you could decorate the ClientCertificates property with [UnsupportedOSPlatform("browser")]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with that. Does it tell an analyzer that you shouldn't use that property? Will it complain at us using it internally for null checks?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll warn if you use that property in a blazor application. Right now SignalR client doesn't claim to support browser so you wouldn't see the error internally. But it would print a warning in the null check once if you say the client targets browser.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SignalR client doesn't claim to support browser

Is this something we should look into in 6.0?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like we have [SupportedOSPlatform("browser")] anywhere yet in this repo or in the runtime repo. I see [UnsupportedOSPlatform("browser")] in a couple places in both repos though.

Why would SignalR need to explicitly claim to support the "browser" platform? If it's opt-in, why put [UnsupportedOSPlatform("browser")] all over?

{
_clientCertificates = new X509CertificateCollection();
}

_cookies = new CookieContainer();

Transports = HttpTransports.All;
Expand Down