OWIN Keys ssl.ClientCertificate always null

Sep 19, 2014 at 10:16 PM
I am developing a Web Api in a web role and i want to authenticate the user using X509 certificate.

When i try try to the key "ssl.ClientCertificate" from the owincontext always return null.

I don't know if im missing something or i need to config something.

Thnak You.
Coordinator
Sep 19, 2014 at 11:10 PM
What client are you using?

Does ssl.ClientCertificateErrors say anything?
https://katanaproject.codeplex.com/wikipage?title=OWIN%20Keys
Sep 20, 2014 at 3:11 AM
Is a windows console the client using HttpClient for the request.

ssl.ClientCertificateErrors doesn't exist in the context either, only exist ssl.LoadClientCertAsync and i already use it for get the client certificate but return null.
Coordinator
Sep 20, 2014 at 1:52 PM
  1. make sure you're using HTTPS.
  2. For HttpClient you have to tell it to use send certs. See WebRequestHandler.ClientCertificates & ClientCertificateOptions.
  3. Check HttpClient's logs to see if it sends the cert. http://msdn.microsoft.com/en-us/library/bb203855.aspx
Jan 5, 2015 at 8:52 PM
Hi, I am running into similar problem where after invoking the ssl.LoadClientCertAsync, I don't see either the certificate or the exception in the dictionary. When I don't set the certificate on the client, ssl.LoadClientCertAsync itself doesn't show up. So my client code is working as expected.

When the async LoadClientCertAsync is invoked, where should i expect the cert to be available for access?

public override async Task Invoke(IOwinContext context)
    {
        var owinCertFunc = "ssl.LoadClientCertAsync";
        var owinCert = "ssl.ClientCertificate";
        var owinCertError = "ssl.ClientCertificateErrors";

        if (context.Environment.Keys.Contains(owinCertFunc))
        {
            try
            {
                var task = (context.Environment[owinCertFunc] as Func<Task>);
                await Task.Run(task);
                X509Certificate cert;
                if(context.Environment.Keys.Contains(owinCert))
                {
                    cert = context.Environment[owinCert] as X509Certificate;
                }
                Exception certError;
                if (context.Environment.Keys.Contains(owinCertError))
                {
                    certError = context.Environment[owinCertError] as Exception;
                }
            }
            catch (Exception ex)
            {                    
                throw;
            }                
        }
        await this.Next.Invoke(context);
    }