public static IHubConnectionBuilder WithUrl(this IHubConnectionBuilder hubConnectionBuilder, Uri url) { if (url == null) { throw new ArgumentNullException(nameof(url)); } hubConnectionBuilder.ConfigureConnectionFactory(() => { var headers = hubConnectionBuilder.GetHeaders(); var httpOptions = new HttpOptions { HttpMessageHandler = hubConnectionBuilder.GetMessageHandler(), Headers = headers != null ? new ReadOnlyDictionary <string, string>(headers) : null, AccessTokenFactory = hubConnectionBuilder.GetAccessTokenFactory(), WebSocketOptions = hubConnectionBuilder.GetWebSocketOptions(), Cookies = hubConnectionBuilder.GetCookies(), Proxy = hubConnectionBuilder.GetProxy(), UseDefaultCredentials = hubConnectionBuilder.GetUseDefaultCredentials(), ClientCertificates = hubConnectionBuilder.GetClientCertificates(), Credentials = hubConnectionBuilder.GetCredentials(), }; return(new HttpConnection(url, hubConnectionBuilder.GetTransport(), hubConnectionBuilder.GetLoggerFactory(), httpOptions)); }); return(hubConnectionBuilder); }
public static IHubConnectionBuilder WithClientCertificate(this IHubConnectionBuilder hubConnectionBuilder, X509Certificate clientCertificate) { if (clientCertificate == null) { throw new ArgumentNullException(nameof(clientCertificate)); } var clientCertificates = hubConnectionBuilder.GetClientCertificates(); if (clientCertificates == null) { clientCertificates = new X509CertificateCollection(); hubConnectionBuilder.AddSetting(ClientCertificatesKey, clientCertificates); } clientCertificates.Add(clientCertificate); return(hubConnectionBuilder); }