Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE

Qlik Sense API: Could not create secure SSL/TLS channel (Powershell)

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
Sonja_Bauernfeind
Digital Support
Digital Support

Qlik Sense API: Could not create secure SSL/TLS channel (Powershell)

Last Update:

Aug 3, 2021 3:54:00 PM

Updated By:

Damien_Villaret

Created date:

Nov 12, 2020 6:36:52 AM

Qlik Sense APIs are returning "Could not create secure SSL/TLS channel" when called from PowerShell.

Environments:

  • Qlik Sense all versions

 

This is not strictly a Qlik Sense issue but due to how PowerShell works.
The error is returned because the connection to the server was not recognized as trusted (because the name in the certificate did not match the URL called for example).

You can simply ignore SSL errors in PowerShell, as described in the reference link below:
https://stackoverflow.com/questions/34331206/ignore-ssl-warning-with-powershell-downloadstring

If you still get an error, or another SSL related error such as "An unexpected error occurred on a send", you might want to also explicitly specifiy to use TLS1.2 for the protocol to send the request.

See sample below:

#ignore certificate/SSL errors
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
    public bool CheckValidationResult(
        ServicePoint srvPoint, X509Certificate certificate,
        WebRequest request, int certificateProblem) {
        return true;
    }
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

#use TLS1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

#API call
$hdrs = @{}
$hdrs.Add("X-Qlik-xrfkey","12345678qwertyui")
$hdrs.Add("X-Qlik-User","UserDirectory=DOMAIN;UserId=Administrator")
$cert = Get-ChildItem -Path "Cert:\CurrentUser\My" | Where {$_.Subject -like '*QlikClient*'}
$url = "https://qlikserver1.domain.local:4242/qrs/about?xrfkey=12345678qwertyui"
$resp = Invoke-RestMethod -Uri $url -Method Get -Headers $hdrs -Certificate $cert
$resp.data.items

 

Labels (1)
Version history
Last update:
‎2021-08-03 03:54 PM
Updated by: