I'm trying to connect to our Qlik Sense server via the .NET SDK. To retrieve the list of apps and sheets.
After creating the connection I'm using the location to retrieve the actual Qlik version as a test. When using the "AsNtlmUserViaProxy" function I get the correct version of Qlik, but when I'm trying to connect via the function "AsDirectConnection" I get the exception "Authentication failed."
I exported a certificate from QMC and installed the client and root certificate on my Windows machine.
I'm using the following code to create the location:
var uri = new Uri("https://***");
ILocation location = Location.FromUri(uri);
var certificatPWD = "****";
byte rawData = File.ReadAllBytes(@"c:\cert\client.pfx");
var x509 = new X509Certificate2(rawData, certificatPWD, X509KeyStorageFlags.MachineKeySet);
var certificateCollection = new X509Certificate2Collection
location.AsDirectConnection(userDirectory: "DOMAIN", userId: "USERNAME", certificateCollection: certificateCollection);
Did you add the engine port to the uri? If you do a direct connection, then you'll need the port. It's typically 4747. So something like https://my.uri:4747
By the way, with the latest versions of the SDK there is a class for doing that certificate loading you are doing. You could write something like this (you'll need to create a secure string of the password though):
var ccertificateCollection = CertificateManager.LoadCertificateFromDirectory(@"c:\cert", certificatePWD);