title: Establishing a SignalR connection when using a self-signed certificate
body: <p>I have a self-hosted WebAPI web service using a self-signed certificate.  I am successfully able to communicate with the web service controller actions from other applications using the URL:  </p>
  
  <pre><code>https://localhost:5150/...
  </code></pre>
  
  <p>Note that I have successfully bound the self-signed certificate to port 5150 and reserved the port for all IPs for my application, both by using the appropriate <em>netsh</em> commands.</p>
  
  <p>I am trying to integrate a SignalR hub into this web service.  I configure the hub, with CORS support, using the following in my startup code:</p>
  
  <pre><code>// Configure the SignalR hub that will talk to the browser
          appBuilder.Map("/signalr", map =&gt;
          {
              map.UseCors(CorsOptions.AllowAll);
  
              HubConfiguration hubConfig = new HubConfiguration();
              hubConfig.EnableDetailedErrors = true;
              hubConfig.EnableJavaScriptProxies = false;
  
              map.RunSignalR(hubConfig);
          });
  </code></pre>
  
  <p>I am starting up my HTTP listener, which is/was also used for Web API by this:</p>
  
  <pre><code>_webApp = WebApp.Start&lt;Startup&gt;(baseUrl);
  </code></pre>
  
  <p>where the baseUrl is</p>
  
  <pre><code>https://+:5150/.
  </code></pre>
  
  <p>My SignalR initialization code, in my Angular controller is:</p>
  
  <pre><code>var initialize = function () {
  
      //Getting the connection object
      connection = $.hubConnection("/signalr", { useDefaultPath: false });
  
      // Url signalr scripts should hit back on the server
      connection.url = ENV.SIGNALR.protocol + '://' + ENV.SIGNALR.server + ':' + ENV.SIGNALR.port + '/' + ENV.SIGNALR.url;
  
      // Turn on client-side logging
      connection.logging = ENV.SIGNALR.logging;
  
      // Get proxy based on Hub name (must be camel-case)
      proxy = connection.createHubProxy('dashboardHub');
  
      // Setup event handlers for messages we get from the server.
      proxy.on('rxDiagnosticMessage', function (msg) {
          //console.log('Received rxDiagnosticMessage');
          $rootScope.$broadcast("rx-diagnostic-message", msg);
      });
  
      //Starting connection
      connection.start()
          .done(function () { console.log('SignalR connection started'); })
          .fail(function (err) { console.log('SignalR connection failed - ' + err); });
  
      // Display errors to console
      connection.error(function (err) {
          console.log('SignalR error - ' + err);
      });
  };
  </code></pre>
  
  <p>When the connection to the hub is attempted, I get the following error:</p>
  
  <pre><code>15:04:43 GMT-0400 (Eastern Daylight Time)] SignalR: Auto detected cross domain url. jquery.signalR-2.1.0.js:81
  [15:04:43 GMT-0400 (Eastern Daylight Time)] SignalR: Client subscribed to hub 'dashboardhub'. jquery.signalR-2.1.0.js:81
  [15:04:43 GMT-0400 (Eastern Daylight Time)] SignalR: Negotiating with 'https://localhost:5150/signalr/negotiate?clientProtocol=1.4&amp;connectionData=%5B%7B%22name%22%3A%22dashboardhub%22%7D%5D'. jquery.signalR-2.1.0.js:81
  GET https://localhost:5150/signalr/negotiate?clientProtocol=1.4&amp;connectionData=%5B%7B%22name%22%3A%22dashboardhub%22%7D%5D&amp;_=1407524683014 net::ERR_INSECURE_RESPONSE jquery-2.1.1.js:8623
  SignalR error - Error: Error during negotiation request. AppSignalR.js:43
  SignalR connection failed - Error: Error during negotiation request. AppSignalR.js:39
  [15:04:43 GMT-0400 (Eastern Daylight Time)] SignalR: Stopping connection.
  </code></pre>
  
  <p>Note the <strong>net::ERR_INSECURE_RESPONSE</strong> during the SignalR connection negotiation.</p>
  
  <p><em>Strange</em> thing...if I run Fiddler2 then the connection works! (Is Fiddler serving up a nice certificate to my web app / SignalR?)</p>
  
  <p>I suspect this is due to the certificate being self-signed (cert in Personal, cert authority in Trusted).  In WCF and WebAPI clients I always intercept the authority errors and bypass the error:</p>
  
  <pre><code>ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) =&gt; true);
  </code></pre>
  
  <p>Is there something similar that needs to be done in the SignalR client in my Angular application?  Or should this just work?</p>
  
  <p>Note that I have seen this thread - <a href="https://stackoverflow.com/questions/18150758/signalr-with-self-signed-ssl-and-self-host....but">SignalR with Self-Signed SSL and Self-Host</a> still does not work for me.</p>