PureStorage-Connect / PowerShellSDK2

Pure Storage FlashArray PowerShell Software Development Kit (SDK) version 2.
https://support.purestorage.com/Solutions/Microsoft_Platform_Guide
Apache License 2.0
8 stars 7 forks source link

Named cert import states that the cert already exists instead of importing the updated cert #22

Open clintsimmons opened 8 months ago

clintsimmons commented 8 months ago

Running this: New-Pfa2Certificate -Certificate $cert1 -IntermediateCertificate $cert2 -Key $key -Passphrase $pp --Name management results in error: New-Pfa2Certificate: Certificate exists (), https://arrayname/api/2.17/certificates?names=management (POST) Expected result: new CA certificate imports and overwrites existing CA certificate (both for updating old cert or moving from self-signed to CA signed).

Also, if attempting to update without using the name parameter it does not tell you which parameter is missing: New-Pfa2Certificate: Missing or invalid parameter. (), https://arrayname/api/2.17/certificates (POST) Expected result: Error plus listing the parameter that was expected.

Utilizing CLI method directly works, although cannot use it via the SDK2 since it is interactive: @purearray> purecert setattr management --certificate --intermediate-certificate --key --passphrase

clintsimmons commented 8 months ago

Forgot to add, using the PATCH method (Update-Pfa2Certificate) - Update-Pfa2Certificate -Certificate $cert1 -Key $keycert1 -IntermediateCertificate $intcert1 -Passphrase $pp -Name management -Verbose Produces "Update-Pfa2Certificate: Failed to load the private key. (), https://arrayname/api/2.17/certificates?names=management (PATCH)"

Verbose: VERBOSE: PureStorage.Rest Verbose: 13 : 2024-01-09T20:17:43.7583398Z Error: Exception "PureRestException: HttpStatusCode = 'BadRequest', RestErrorCode = 'InternalError', Details = '[{"context":null,"message":"Failed to load the private key.\n"},{"context":"PATCH","message":"https://arrayname/api/2.17/certificates?names=management"}]', InnerException = ''", StackTrace= at PureStorage.FlashArray.Rest.Api.CertificatesApi.Api224CertificatesPatchWithHttpInfo(CertificatePost certificate, String authorization, String xRequestID, List1 names, Nullable1 generateNewKey, String apiVersion) at PureStorage.FlashArray.Rest.Rest2Api.<>cDisplayClass132_0.b0() at PureStorage.Rest.PureClient.DoRetries[T](String method, String path, String apiVersion, Func`1 retriable)

VERBOSE: PureStorage.Rest Error: 12 : 2024-01-09T20:17:43.7586037Z '"PureRestException: HttpStatusCode = 'BadRequest', RestErrorCode = 'InternalError', Details = '[{"context":null,"message":"Failed to load the private key.\n"},{"context":"PATCH","message":"https://arrayname/api/2.17/certificates?names=management"}]', InnerException = ''"'

VERBOSE: PureStorage.Rest Verbose: 13 : 2024-01-09T20:17:43.7587721Z Parameter: HttpHeader:x-auth-token=ff8fbb15-3ab8-4d9d-ac12-dd04b315010d

VERBOSE: PureStorage.Rest Verbose: 13 : 2024-01-09T20:17:43.7589009Z Parameter: HttpHeader:Accept=application/json

VERBOSE: PureStorage.Rest Verbose: 13 : 2024-01-09T20:17:43.7590447Z Parameter: QueryString:names=management

mikenelson-io commented 8 months ago

From engineering-

The expected behavior for New-Pfa2Certificate when the cert already exists is to return an error. It is working as wexpected.

However, for Update-Pfa2Certificates, it would be nice if the error message has more details on what parameters are missing.

This is an issue that is being tracked internally.