samwoo Posted November 29, 2019 Posted November 29, 2019 Hi, I have just attempted to run one of the PowerShell script that I used before to interact with the Hornbill API and I am getting the following error message: The request was aborted: Could not create SSL/TLS secure channel. Checking with the network guys they have said that TLS/SSL is enabled on the server i have been running this from, and the communication between that server and the IP address of the Hornbill API instance is getting through and bouncing back, yet this error message still persists. Please can someone advise? Basically the query that i am currently running simply extracts a list of all the users. Get All HB Users.ps1 #=================================================================== # Loop through functions folder and import them #=================================================================== $function_files = get-childitem 'C:\Scripts\Hornbill\Functions\fnc*' foreach($file in $function_files) { . $file.FullName } #=================================================================== # Import Modules #=================================================================== Import-Module -Name HornbillAPI Import-Module -Name HornbillHelpers #=================================================================== # Set up the Hornbill connection and instance details #=================================================================== $v_instanceName = "<INSTANCENAME>" $v_instanceZone = "eur" $v_APIKey = "<APIKEY>" #=================================================================== # Connect to the Hornbill instance #=================================================================== Set-HB-Instance -Instance $v_instanceName -Zone $v_instanceZone -Key $v_APIKey #=================================================================== # Get all the users #=================================================================== Get-HB-All-Users fnc_Get-HB-All-Users.ps1 function Get-HB-All-Users { #=================================================================== # Create the object #=================================================================== $output_Object = [PSCustomObject]@{ status = "" error = "" object = "" } #=================================================================== # Run the API #=================================================================== Add-HB-Param "application" "com.hornbill.servicemanager" Add-HB-Param "entity" "UserAccount" Open-HB-Element "searchFilter" Add-HB-Param "column" "h_account_status" Add-HB-Param "value" "0" Close-HB-Element "searchFilter" $XMLMC_hb_customer = Invoke-HB-XMLMC "data" "entitybrowserecords2" #=================================================================== # Check the API was successful or not #=================================================================== if($XMLMC_hb_customer.status -ne "Ok") { $output_Object.status = "Fail" $output_Object.error = $XMLMC_hb_customer.error } else { $output_Object.status = "Ok" $output_Object.object = $XMLMC_hb_customer.Params.rowdata.row } return $output_Object } #=================================================================== # Return sucess to the user #=================================================================== if(get-command Get-HB-All-Users) { Write-Host "[Function] Get-HB-All-Users loaded succesfully..." -ForegroundColor Green } I haven't run any Hornbill API's using PowerShell for over a month or two ago due to other work, but I am needed to do this again and am unable to. Please advise. Thanks, Samuel
SamS Posted November 29, 2019 Posted November 29, 2019 Hi @samwoo, I cannot recreate your issue myself (it seems a Powershell error), so it seems unlikely that the issue is our server. Could you please run the following on your PowerShell command line: [Net.ServicePointManager]::SecurityProtocol This should identify what security protocol is currently set. If the result does not contain not TLS ("Tls" in Powershell speak), run the following before trying the script: [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
samwoo Posted November 29, 2019 Author Posted November 29, 2019 2 minutes ago, SamS said: Hi @samwoo, I cannot recreate your issue myself (it seems a Powershell error), so it seems unlikely that the issue is our server. Could you please run the following on your PowerShell command line: [Net.ServicePointManager]::SecurityProtocol This should identify what security protocol is currently set. If the result does not contain not TLS ("Tls" in Powershell speak), run the following before trying the script: [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Hi @SamS, That is funny as I just found this out myself literally moments ago - i added the following to the top of the script and it worked: [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" Not sure what's happened in the first place though... Thanks, Samuel
SamS Posted November 29, 2019 Posted November 29, 2019 Hi @samwoo, When I run [Net.ServicePointManager]::SecurityProtocol I get "SystemDefault" returned. From what I gather this is defined in a registry entry specific to the .Net framework in use. So, I would gather that one of the following might have happened: An upgrade/removal of a .Net version A tweak to the registry to fix some other script
samwoo Posted November 29, 2019 Author Posted November 29, 2019 Hi again @SamS, Trying it with just tls12 doesn't work.. [Net.ServicePointManager]::SecurityProtocol = "tls12" Unable to connect to the remote server Thanks, Samuel
samwoo Posted November 29, 2019 Author Posted November 29, 2019 Just now, SamS said: Hi @samwoo, When I run [Net.ServicePointManager]::SecurityProtocol I get "SystemDefault" returned. From what I gather this is defined in a registry entry specific to the .Net framework in use. So, I would gather that one of the following might have happened: An upgrade/removal of a .Net version A tweak to the registry to fix some other script Thanks @SamS, I believe that .NET was upgraded Thanks, Samuel
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now