Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Partner
Partner

.NET SDK Connect Using Certificates

Hi

I have been able to connect QRS Rest API using Certificates and X-Qlik-User now I need the same to connect using the .NET SDK.

How can we authenticate to the .NET SDK using certificates?

Thanks

1 Solution

Accepted Solutions
Luminary
Luminary

Re: .NET SDK Connect Using Certificates

Hi,

this is at the moment not possible. As a workaround. Connect with certificate and .net web requests, get the Qlik-Session-ID ans use the following code:

public static class LocationExtensions_akquinet

    {

        private static Logger logger = LogManager.GetCurrentClassLogger();

        public static void AsExistingSessionViaProxy(this ILocation location, string sessionId, bool useSsl = true, string cookieHeaderName = null)

        {

            var SecurityProperty = location.GetType().GetProperty("Qlik.Engine.ISecureLocation.Security", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

            var Security = SecurityConfigurator.OpenAsExistingSessionViaProxy(sessionId, useSsl, cookieHeaderName ?? "X-Qlik-Session");

            SecurityProperty.SetValue(location, Security);

        }

        private static PropertyInfo SecurityConfiguratorProperty = null;

        internal static Qlik.Sense.Communication.Communication.Security.ISecurityConfigurator SecurityConfigurator

        {

            get

            {

                if (SecurityConfiguratorProperty == null)

                    SecurityConfiguratorProperty = typeof(LocationExtensions).GetProperty("SecurityConfigurator", BindingFlags.Static | BindingFlags.NonPublic);

                return SecurityConfiguratorProperty.GetValue(null) as Qlik.Sense.Communication.Communication.Security.SecurityConfigurator;

            }

        }

10 Replies
Luminary
Luminary

Re: .NET SDK Connect Using Certificates

Hi,

this is at the moment not possible. As a workaround. Connect with certificate and .net web requests, get the Qlik-Session-ID ans use the following code:

public static class LocationExtensions_akquinet

    {

        private static Logger logger = LogManager.GetCurrentClassLogger();

        public static void AsExistingSessionViaProxy(this ILocation location, string sessionId, bool useSsl = true, string cookieHeaderName = null)

        {

            var SecurityProperty = location.GetType().GetProperty("Qlik.Engine.ISecureLocation.Security", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

            var Security = SecurityConfigurator.OpenAsExistingSessionViaProxy(sessionId, useSsl, cookieHeaderName ?? "X-Qlik-Session");

            SecurityProperty.SetValue(location, Security);

        }

        private static PropertyInfo SecurityConfiguratorProperty = null;

        internal static Qlik.Sense.Communication.Communication.Security.ISecurityConfigurator SecurityConfigurator

        {

            get

            {

                if (SecurityConfiguratorProperty == null)

                    SecurityConfiguratorProperty = typeof(LocationExtensions).GetProperty("SecurityConfigurator", BindingFlags.Static | BindingFlags.NonPublic);

                return SecurityConfiguratorProperty.GetValue(null) as Qlik.Sense.Communication.Communication.Security.SecurityConfigurator;

            }

        }

Partner
Partner

Re: .NET SDK Connect Using Certificates

Hi Konrad,

How can I use this code do you have a sample, is it ok if I open a Rest Api QRS Connection with certificate (It work) then how can I recuperate the SessionId and pass it to your function?

What do we have to pur for cookieHeaderName

Thanks a lot Konrad

By the way are you working in akquinet I see that we have a meeting tomorrow to betatest Version Manager for Qlik Sense 😉

JP

Luminary
Luminary

Re: .NET SDK Connect Using Certificates

Hi JP,

yes I'm Konrad from the akquinet, so we can dicuss that together with the Version Manager session.

But I think we don't have that session tomorrow. I have a session with Craig next Tue 13-14:00. Just join that session.

bye

Konrad

Partner
Partner

Re: .NET SDK Connect Using Certificates

Cool,

In the meanwhile do you have a small sample of usage of your code

Thanks

Highlighted
Luminary
Luminary

Re: .NET SDK Connect Using Certificates

Hi JP,

I don't understand what you need more. Make a HttpRequest with Certificate, take the response Cockie,

take the CockieKey and CockieValue and have this nice class. And than you can write

location.AsExistingSessionViaProxy(CockieKey, CockieValue) thats all.

bye Konrad

Partner
Partner

Re: .NET SDK Connect Using Certificates

I try this and get a StackOverflow Exception here running in a loop

if (SecurityConfiguratorProperty == null)

                    SecurityConfiguratorProperty = typeof(LocationExtensions).GetProperty("SecurityConfigurator", BindingFlags.Static | BindingFlags.NonPublic);

                return SecurityConfiguratorProperty.GetValue(null) as Qlik.Sense.Communication.Communication.Security.SecurityConfigurator;

Luminary
Luminary

Re: .NET SDK Connect Using Certificates

Hi JP,

i don't know what you are doing around with that code, but this code is perfectly working in our plugin (sense-excel).

You can build a small sample app with certificate and upload it here and I can check it, or we can look at it next week (tuesday) together on your code.

bye Konrad

Partner
Partner

Re: .NET SDK Connect Using Certificates

Hi Conrad now seem that it is working, great thanks.

It just now miss the certificate injection in the .NET session. If the certificate is in the windows certmgr it's ok but i would prefer to inject it manually as i do in Rest. Do you have an idea how to proceed in .NET?

Thanks JP

Luminary
Luminary

Re: .NET SDK Connect Using Certificates