<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>article Qlik Sense API: Could not create secure SSL/TLS channel (Powershell) in Official Support Articles</title>
    <link>https://community.qlik.com/t5/Official-Support-Articles/Qlik-Sense-API-Could-not-create-secure-SSL-TLS-channel/ta-p/1761100</link>
    <description>&lt;DIV class="lia-message-template-content-zone"&gt;
&lt;P&gt;Qlik Sense APIs are returning "Could not create secure SSL/TLS channel" when called from PowerShell.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Environments:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Qlik Sense all versions&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is not strictly a Qlik Sense issue but due to how PowerShell works.&lt;BR /&gt;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).&lt;BR /&gt;&lt;BR /&gt;You can simply ignore SSL errors in PowerShell, as described in the reference link below:&lt;BR /&gt;&lt;A href="https://stackoverflow.com/questions/34331206/ignore-ssl-warning-with-powershell-downloadstring" target="_blank" rel="noopener" data-cke-saved-href="https://stackoverflow.com/questions/34331206/ignore-ssl-warning-with-powershell-downloadstring"&gt;https://stackoverflow.com/questions/34331206/ignore-ssl-warning-with-powershell-downloadstring&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;See sample below:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;#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&lt;BR /&gt;$resp.data.items&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;</description>
    <pubDate>Tue, 03 Aug 2021 19:54:00 GMT</pubDate>
    <dc:creator>Sonja_Bauernfeind</dc:creator>
    <dc:date>2021-08-03T19:54:00Z</dc:date>
    <item>
      <title>Qlik Sense API: Could not create secure SSL/TLS channel (Powershell)</title>
      <link>https://community.qlik.com/t5/Official-Support-Articles/Qlik-Sense-API-Could-not-create-secure-SSL-TLS-channel/ta-p/1761100</link>
      <description>&lt;DIV class="lia-message-template-content-zone"&gt;
&lt;P&gt;Qlik Sense APIs are returning "Could not create secure SSL/TLS channel" when called from PowerShell.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Environments:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Qlik Sense all versions&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is not strictly a Qlik Sense issue but due to how PowerShell works.&lt;BR /&gt;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).&lt;BR /&gt;&lt;BR /&gt;You can simply ignore SSL errors in PowerShell, as described in the reference link below:&lt;BR /&gt;&lt;A href="https://stackoverflow.com/questions/34331206/ignore-ssl-warning-with-powershell-downloadstring" target="_blank" rel="noopener" data-cke-saved-href="https://stackoverflow.com/questions/34331206/ignore-ssl-warning-with-powershell-downloadstring"&gt;https://stackoverflow.com/questions/34331206/ignore-ssl-warning-with-powershell-downloadstring&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;See sample below:&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;#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&lt;BR /&gt;$resp.data.items&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 03 Aug 2021 19:54:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Official-Support-Articles/Qlik-Sense-API-Could-not-create-secure-SSL-TLS-channel/ta-p/1761100</guid>
      <dc:creator>Sonja_Bauernfeind</dc:creator>
      <dc:date>2021-08-03T19:54:00Z</dc:date>
    </item>
  </channel>
</rss>

