
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Qlik Sense API: Could not create secure SSL/TLS channel (Powershell)
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