Topics on this page
Set up to use Bash or PowerShell
Set up your environment to use Bash (cURL) or PowerShell to send HTTP requests to Workload Security using the API.
Complete this recipe before performing any other cookbook recipes.
Bash or PowerShell?
If you are new to scripting, you might not be familiar with these tools. Your operating system determines which one you will be using:
- Windows: PowerShell
- Mac or Linux: Bash
If you are on Windows, you can ignore the information about Bash (and cURL). Conversely, if you are using Bash, you can ignore all the PowerShell information.
Check your environment
Check that you can access Workload Security and that you have the required software installed. Check the version of your software to make sure it supports TLS 1.2, which Workload Security uses for securing HTTPS connections.
Check your connection to Workload Security
Use your Web browser to navigate to Workload Security https://cloudone.trendmicro.com:
- If the page opens then you have the required network access.
- If you cannot open the page, check that you have a network connection and that your URL is correct.
Check your cURL software
If you want to use Bash (typically Linux or Mac users), check the version of cURL and OpenSSL or NSS or LibreSSL that are installed. Open Terminal or your preferred command line tool and enter the following command:
curl --version
- Make sure you have cURL 7.34.0 or later
- Locate one of the following libraries in the output:
- OpenSSL 1.01 or later (1.02 recommended)
- Network Security Services (NSS) 3.15.1 or later
- LibreSSL 2.1.4 or later
- A different library that secures network communications and supports TLS 1.2
If any of the required software is not installed or is too old, refer to your operating system's documentation for information about installing or upgrading it.
Check your PowerShell software
If you want to use PowerShell (Windows), check the version of PowerShell and .NET Framework that is installed.
-
To check that your version of PowerShell is 3.0 or later, open PowerShell, enter the following command, and check that the value of
PSVersion
is 3.0 or later:$psversiontable
-
To check that your version of .NET Framework is 4.5 or later, enter the following command that returns the version from the registry:
(Get-Childitem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full').GetValue("Version")
If PowerShell or .NET Framework is not installed or is too old, refer to your Windows documentation for information about installing or upgrading it.
Create an API key
Create an API key for authenticating your API calls. When you create the key, a key secret is presented that you must store for later use.
Store the key secret in a secure manner and do not share it.
- For information on how to create an API key for legacy accounts, see Create and Manage API Keys.
- For information on how to create an API key for new Trend Cloud One accounts, see Manage API keys.
If you are not sure whether you are using a new account or a legacy account, see Changes to Trend Cloud One accounts.
Test your setup
Bash
-
Open Terminal or your preferred command line tool.
-
Enter the following commands to store details about your request, replacing
<YOUR URL>
with the URL of Workload Security, and<YOUR SECRET KEY>
with the secret from your API key:-
url=<YOUR URL>
For example,
url=https://cloudone.trendmicro.com
-
secret=<YOUR SECRET KEY>
For example,
secret=5C58EADA-04BC-4ABC-45CF-B72925A0B674:aFBgpPV8eJQGaY2Dk0LmyQMD7nUGvyIDfIbIQo8Zgm8=
-
-
Enter the following command to send the request:
curl -X GET $url/api/apikeys -H "api-secret-key: $secret" -H "api-version: v1" -s -w "\n\nresponse code: %{response_code}\n"
If the response ends with
response code: 200
, your call was successful and your setup is validated.
PowerShell
-
Open PowerShell.
-
Enter the following command to use TLS 1.2:
[Net.ServicePointManager]::SecurityProtocol += [Net.SecurityProtocolType]::Tls12
-
Enter the following commands to store details about your request, replacing
<YOUR URL>
with the URL of Workload Security, and<YOUR SECRET KEY>
with the secret from your API key:$url = "_<YOUR URL>_"
For example,url=https://cloudone.trendmicro.com
$secret = "_<YOUR API KEY SECRET>_"
For example,$secret="5C58EADA-04BC-4ABC-45CF-B72725A0B674:aFBgpPV8eJQGaY2Dk0LmyQMD7nUGvyIDfIbIQo8Zgm8="
$headers = @{'api-version' = "v1"; 'api-secret-key' = $secret}
-
Enter the following command to send the request:
Invoke-WebRequest "$url/api/apikeys" -Headers $headers
If the response that appears includes
StatusCode : 200
, your call was successful and your setup is validated.If you receive the error message
The underlying connection was closed: An unexpected error occurred on a send
, close PowerShell, open PowerShell again, and try repeating the test.
Final comments
After you have successfully sent a request to Workload Security to validate your setup, you are ready to use the other cookbook recipes.
Related resources
- API Cookbooks
- Control Access Using Roles
- Create and Manage API Keys