I want to create a simple SignalR application. Using http everything works fine, but when I try to use https and certificates, the application does not work.
Currently, the only thing I want to do is get the client certificate on the server.
Server (authentication handler):
public class ClientCertificateAuthenticationHandler : AuthenticationHandler<ClientCertificateAuthenticationOptions> { protected override Task<AuthenticationTicket> AuthenticateCoreAsync() { var cert = Context.Get<X509Certificate>("ssl.ClientCertificate"); if (cert == null) { return Task.FromResult<AuthenticationTicket>(null); } try { Options.Validator.Validate(cert); } catch { return Task.FromResult<AuthenticationTicket>(null); } return null; } }
Client (hub)
var connection = new HubConnection("https://localhost:8080/"); connection.AddClientCertificate(X509Certificate.CreateFromCertFile("c1.cer")); IHubProxy myHub = connection.CreateHubProxy("MyHub"); connection.Start().Wait();
By doing this, on the server, when I do var cert = Context.Get<X509Certificate>("ssl.ClientCertificate"); I get null .
So what am I doing wrong?
source share