Skip to content

[BUG] API Cert Upload Changes Domain_Names #4245

Open
@MeCJay12

Description

@MeCJay12

Checklist

  • Have you pulled and found the error with jc21/nginx-proxy-manager:latest docker image?
    • X Yes / No
  • Are you sure you're not using someone else's docker image?
    • X Yes / No
  • Have you searched for similar issues (both open and closed)?
    • X Yes / No

Describe the bug
When uploading certificate keys via the API, domain_names is reset to match the CN of the certificate which doesn't match the SAN of a certificate with multiple domains.

Nginx Proxy Manager Version
v2.12.1

To Reproduce

  1. Use the API to create a certificate object:
    url = f"http://npm.exmaple.com/api/nginx/certificates/"
    headers = { "Authorization": f"Bearer " + api_key }

    data = {
      "provider": "other",
      "nice_name": "speed.example.com, speed.ext.example.com",
      "domain_names": ['speed.example.com', 'speed.ext.example.com']
    }

    response = requests.post(url, headers=headers, json=data)
    id = response.json().get('id')
  1. Upload keys to the certificate object:
    url = f"http://npm.exmaple.com/api/nginx/certificates/{id}/upload"

    # public, chain, and private are variables containing respective keys
    files = {
      "certificate": ("cert.pem", public),
      "certificate_key": ("privekey.pem", private),
      "intermediate_certificate": ("chain.pem", chain)
    }

    response = requests.post(url, headers=headers, files=files)
  1. View certificate:
url = f"http://npm.exmaple.com/api/nginx/certificates/{id}
response = requests.get(url, headers=headers)
print(json.dumps(response.json(), indent=2))

{
  "id": 22,
  "created_on": "2024-12-19T02:56:58.000Z",
  "modified_on": "2024-12-19T02:56:59.000Z",
  "owner_user_id": 1,
  "provider": "other",
  "nice_name": "speed.example.com, speed.ext.example.com",
  "domain_names": [
    "speed.example.com"                                                       <<<<<<<<<<<
  ],
  "expires_on": "2025-01-29T11:48:02.000Z",
  "meta": {
    "certificate": "-----BEGIN CERTIFICATE-----...",
    "certificate_key": "-----BEGIN PRIVATE KEY-----...",
    "intermediate_certificate": "-----BEGIN CERTIFICATE-----..."
  }
}

Expected behavior

{
  "id": 22,
  "created_on": "2024-12-19T02:56:58.000Z",
  "modified_on": "2024-12-19T02:56:59.000Z",
  "owner_user_id": 1,
  "provider": "other",
  "nice_name": "speed.example.com, speed.ext.example.com",
  "domain_names": [
    "speed.example.com",                                                        <<<<<<<<<<<
    "speed.ext.example.com"                                                   <<<<<<<<<<<
  ],
  "expires_on": "2025-01-29T11:48:02.000Z",
  "meta": {
    "certificate": "-----BEGIN CERTIFICATE-----...",
    "certificate_key": "-----BEGIN PRIVATE KEY-----...",
    "intermediate_certificate": "-----BEGIN CERTIFICATE-----..."
  }
}

Screenshots
All CLI

Operating System
Script run on Windows with Python v3.12.7 connecting to NPM as a Docker container on Ubuntu 22.04.5 LTS

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions