Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB import command not working without cert_digest under ca_certificates in declarative config #12110

Open
1 task done
guillaumesmo opened this issue Nov 28, 2023 · 1 comment

Comments

@guillaumesmo
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Kong version ($ kong version)

3.4

Current Behavior

_format_version: '3.0'
_transform: false
ca_certificates:
  - id: 85a67812-678c-5fe5-9ff1-60af91f31b4b
    cert: |
      -----BEGIN CERTIFICATE-----
      ...
      -----END CERTIFICATE-----

Output of kong config db_import:

parse successful, beginning import
Error: Failed importing:
[postgres] primary key violation on key '{id="85a67812-678c-5fe5-9ff1-60af91f31b4b"}'

  Run with --v (verbose) or --vv (debug) for more details

The error message was misleading as the database didn't have any records in the ca_certificates table. However, logging on the database revealed the underlying issue:

ERROR:  null value in column "cert_digest" of relation "ca_certificates" violates not-null constraint
DETAIL:  Failing row contains (85a67812-678c-5fe5-9ff1-60af91f31b4b, 2023-11-28 13:42:58+00, -----BEGIN CERTIFICATE-----
2023-11-28 14:42:58    ..., null, null, 2023-11-28 13:42:58+00).

As a workaround, it's possible to add the "cert_digest" key to the CA certificate, however that is not consistent with the API for which cert_digest is optional and also the DB-less mode which works fine without that key.

Expected Behavior

I expect the db_import command to allow ca_certificates without mentioning cert_digest.

This should either store it in database with a null value (and handle that properly afterwards) or generate a digest on the fly when importing ( as already the case in the API I believe - see https://github.com/Kong/kong/blob/3.4.0/kong/db/schema/entities/ca_certificates.lua#L32 )

Steps To Reproduce

No response

Anything else?

No response

@bungle
Copy link
Member

bungle commented Dec 4, 2023

Internal ticket: KAG-3280

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants