I'm trying to import a certificate that I already have generated into TrueNAS with it's API.
I think I have the script right because it returns 200/OK, but it doesn't show up in the certificate list with the GET API call nor the UI!
Here's my powershell:
I then receive this as an output:
But as I said before - still no certificate is populated.
Any help would be amazing, I am terrible at APIs and they frustrate me quite considerably.
Thanks!
I think I have the script right because it returns 200/OK, but it doesn't show up in the certificate list with the GET API call nor the UI!
Here's my powershell:
Code:
# Define the URL of the API endpoint where you want to make the request $endpointUrl = "https://truenas.mydomain.local/api/v2.0/certificate/" $Cert = Get-Content -Path "C:\Windows\Temp\tempcerts\certchain.crt" -Raw $PrivKey = Get-Content -Path "C:\Windows\Temp\tempcerts\key.key" -Raw # Define the JSON data $jsonData = @" { "create_type": "CERTIFICATE_CREATE_IMPORTED", "name": "TESTAPI", "certificate": "$Cert", "privatekey": "$PrivKey" } "@ $jsonData = $jsonData | ConvertTo-Json -Depth 100 # Set the content type for the request $headers = @{ "Authorization" = "Bearer API_KEY" } # Make the request using Invoke-WebRequest $response = Invoke-RestMethod -Uri $endpointUrl -Method POST -Headers $headers -Body $JSONString -ContentType "application/json" # Output the response $response
I then receive this as an output:
Code:
StatusCode : 200 StatusDescription : OK Content : 138 RawContent : HTTP/1.1 200 OK Connection: keep-alive Strict-Transport-Security: max-age=63072000; includeSubDomains; preload X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block Permissions-Policy: ... Forms : {} Headers : {[Connection, keep-alive], [Strict-Transport-Security, max-age=63072000; includeSubDomains; preload], [X-Content-Type-Options, nosniff], [X-XSS-Protection, 1; mode=block]...} Images : {} InputFields : {} Links : {} ParsedHtml : System.__ComObject RawContentLength : 3
But as I said before - still no certificate is populated.
Any help would be amazing, I am terrible at APIs and they frustrate me quite considerably.
Thanks!