Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
jp_golay
Partner - Creator II
Partner - Creator II

.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

ebiexperts CTO
With WIP, Control everything!
Qlik Sense, QlikView and NPrinting Source control, Versioning and Deployment, Agile Lifecycle Management
1 Solution

Accepted Solutions
konrad_mattheis
Luminary Alumni
Luminary Alumni

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;

            }

        }

View solution in original post

10 Replies
konrad_mattheis
Luminary Alumni
Luminary Alumni

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;

            }

        }

jp_golay
Partner - Creator II
Partner - Creator II
Author

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

ebiexperts CTO
With WIP, Control everything!
Qlik Sense, QlikView and NPrinting Source control, Versioning and Deployment, Agile Lifecycle Management
konrad_mattheis
Luminary Alumni
Luminary Alumni

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

jp_golay
Partner - Creator II
Partner - Creator II
Author

Cool,

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

Thanks

ebiexperts CTO
With WIP, Control everything!
Qlik Sense, QlikView and NPrinting Source control, Versioning and Deployment, Agile Lifecycle Management
konrad_mattheis
Luminary Alumni
Luminary Alumni

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

jp_golay
Partner - Creator II
Partner - Creator II
Author

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;

ebiexperts CTO
With WIP, Control everything!
Qlik Sense, QlikView and NPrinting Source control, Versioning and Deployment, Agile Lifecycle Management
konrad_mattheis
Luminary Alumni
Luminary Alumni

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

jp_golay
Partner - Creator II
Partner - Creator II
Author

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

ebiexperts CTO
With WIP, Control everything!
Qlik Sense, QlikView and NPrinting Source control, Versioning and Deployment, Agile Lifecycle Management