locked
SignalR Unable to Authentication with Certificate RRS feed

  • Question

  • User-1183929174 posted

    I would like to authenticate my signalr clients using certificate.

    On the client side I have:

    Connection = new HubConnection(ServerUri);
    var certificate = new X509Certificate2(path);
    Connection.AddClientCertificate(certificate);
    HubProxy = Connection.CreateHubProxy("MyHub");

    I also tried to create a certificate with private key:

    var certificate = new X509Certificate2(path, "...");
    

    On the server I have this config:

    <location path="signalr">
      <system.webServer>
        <security>
          <access sslFlags="SslNegotiateCert" />
        </security>
      </system.webServer>
    </location>
    

    And to get the certificate I tried:

    Context.Request.GetHttpContext().Request.ClientCertificate
    Context.Request.Environment.TryGetValue("ssl.ClientCertificate", out cert)
    

    The first problem is path="signalr". When I use this, the client cannot connect to the server and I get:

    HTTP Error 500.19 - Internal Server Error
    The requested page cannot be accessed because the related configuration data 
    for the page is invalid.
    

    I tried: path="~" , path="signalr/content" , path="signalr/send" and there is no error but the client certificate on the server is always null.

    Any help would be greatly appreciated.

    Thursday, January 15, 2015 10:17 AM

All replies

  • User-271186128 posted

    Hi payamgerami,

    Welcome to ASP.NET forum.

    payamgerami

    HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.

    As for this issue, here is an article about 500.19 error, you could check out the causes and try the solutions. 

    http://support.microsoft.com/kb/942055

    Besides, here are some similar threads, you could refer to them.

    http://forums.iis.net/t/1195432.aspx

    http://forums.iis.net/t/1170024.aspx

    payamgerami

    SignalR Unable to Authentication with Certificate

    As for this issue, here is a tutorial about Authentication and Authorization for SignalR Hubs. Please refer to it.

    http://www.asp.net/signalr/overview/security/hub-authorization

    Besides, here is a similar thread, you could refer to it.

    http://stackoverflow.com/questions/26297675/signalr-with-certificates

    Best Regards,
    Dillion

    Thursday, January 15, 2015 10:34 PM
  • User-1183929174 posted

    Thank you for the reply.
    I have read all the links you refered to already but non of them actually solve the specific problem that I have. 
    The issue is not about authentication in general, It is specifically about adding a client certificate on the client side and getting that certificate on the signalr server. 
    So far, I could not manage to make it work, there is either a server error or the certificate on the server is null.
    If you have a working sample that you add a client certificate on the client side and getting it on the server, I would greatly appreciate if you could send me that.

    Friday, January 16, 2015 8:37 AM
  • User-1161676564 posted

    I have found the root cause of this whole issue. It turns out that the Signalr is a pickier than web api as far as client certificate authentication. 

    Friday, December 11, 2015 8:23 PM
  • User-988440538 posted

    payamgerami,

    Are you able to find solution for SignalR Unable to Authentication with Certificate

    I am also facing same Issue.If dont mind can you please send me complate code to sudhakar.kukkala@outlook.com

    Wednesday, November 9, 2016 9:41 PM