OPNsense Forum

English Forums => 25.7 Series => Topic started by: ProximusAl on September 18, 2025, 10:01:42 AM

Title: [SOLVED] OPNSense API to import TLS Certificates
Post by: ProximusAl on September 18, 2025, 10:01:42 AM
I'm trying to use the API to import a new TLS certificate for the WebGUI.

I keep getting:
HTTP 500
{"errorMessage":"Invalid private key provided: cannot parse private key data","errorTitle":"Certificate error"}

The certificate is an EC certificate that is accepted manually by the GUI, but is there something in the API that wont accept an EC private key?
e.g.: -----BEGIN EC PRIVATE KEY-----

I've got a feeling this will work with an RSA certificate, but as I don't have one, its hard to test.

TIA
Title: [SOLVED] Re: OPNSense API to import TLS Certificates
Post by: ProximusAl on September 18, 2025, 10:25:44 AM
Ahhh, solved.  It was the \r \n formatting in the key.

Got it working now

$keyPem  = (Get-Content -Raw $PrivKeyPath)   -replace "`r`n","`n"