j81blog / GenLeCertForNS

This script helps you to create a Let's Encrypt certificate for your NetScaler
GNU General Public License v3.0
39 stars 16 forks source link

Get-ADCCurrentCertificate function #1

Closed StefanoN-Infotronics closed 3 years ago

StefanoN-Infotronics commented 4 years ago

The payload for the systemfile REST api requires a filename and location. You are passing in a fully pathed filename, which it should be JUST the filename. It does not find the file otherwise. I am using version 13 of the ADC

j81blog commented 4 years ago

Not sure I'm following you? At line 556 I'm creating the headers with filename what will get the name of the file (and part of the path relative to "/nsconfig/ssl/"and I specify the filelocation with value "/nsconfig/ssl/".

$adcCert = Invoke-ADCRestApi -Session $Session -Method GET -Type sslcertkey -Resource $Name -ErrorAction SilentlyContinue
$currentCert = $adcCert.sslcertkey
$payload = @{"filename" = "$($currentCert.cert)"; "filelocation" = "/nsconfig/ssl/" }
$response = Invoke-ADCRestApi -Session $Session -Method GET -Type systemfile -Arguments $payload -ErrorAction SilentlyContinue

Then I'm Getting the file. I just verified it and it works even is certs are in a sub directory, I'm also currently using 13.0 for main testing.

StefanoN-Infotronics commented 4 years ago

That is strange. I get a file not found unless i change the $payload line to: $payload = @{"filename" = "$(Split-Path $currentCert.cert -leaf)"; "filelocation" = "/nsconfig/ssl/" }

Without the split-path, I get the full path to the file as the filename, not just the relative path

j81blog commented 3 years ago

I've changed a lot in the recent Dev build, can you verify if you still have any issues?

j81blog commented 3 years ago

Removed the "Get-ADCCurrentCertificate" and related code. as this didn't worked as intended. Implemented other methods. The other issues should be resolved in earlier versions (also in the latest v2.9.0 version)