SonicOS API Endpoint for Importing SSL Certificate
I'm having difficulty figuring out how to get my new SSL certificate from Let's Encrypt installed on my SonicWALL device via the SonicOS API. I'm calling the certificates-import-cert-key-pair endpoint with an HTTP PUT request as according to the Swagger documentation:
https://[SONICWALL_IP]:[PORT]/api/sonicos/certificates/import/cert-key-pair/name/"sub.domain.com [Certify] 3/11/2022 10:06:59 AM to 6/9/2022 11:06:58 AM"/password/"[PFX_P@$$w0?d]"/ftp/ftp%3a%2f%2f[FTP_USER]%3a[FTP_PASS]%40[FTP_SERVER_IP]%2f20220609_49b0413b.pfx
I've verified that the PFX file is on the FTP server and accessible to the FTP_USER account but, when I try to call this endpoint, I get a
404 - Not Found response.
I'm using (VB).NET to construct the API URL from an
X509Certificate2 object to get the Friendly Name to use for the name element of the API call. The password element is populated from a
Net.NetworkCredential object. The request is being sent as a
System.Net.WebRequest object with the following properties:
.Method = "PUT"
.ContentType = "text/plain, application/json"
.Accept = "text/plain, application/json"
.PreAuthenticate = True
.Headers("Authorization") = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(Username + ":" + Password))
.Headers("Accept-Encoding") = "text/plain, application/json"
.Headers("Charset") = "UTF-8"
After looking at this thread from nearly a year ago, I tried flipping the API URL elements for certificates and import:
but I still get the
404 - Not Found error.
Also from that thread, I tried reading the PFX file's raw data into a byte array and submitting it as the request's content with
Content-Type: multipart/form-data, as well as
Content-Type: application/octet-stream (to the original endpoint), but those didn't work either, this time returning a
406 - Not Acceptable error.
I have not yet tried with the
/api/sonicos/direct/cli option presented in that thread, but that's probably going to be my next step in trying to make this work. I'm probably just overlooking something or being "dense" here, but perhaps someone could point me in the right direction.