kn secret create --tls-cert creates the certificate under the wrong key

Open Beginner friendly
#2,284 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@RaphaelFakhri is already working on this.

Since Nov 4, 2026.

  • #2285 by @RaphaelFakhri — open

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
91/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go, kubernetes
Domain
cli

Research direction

The issue points to pkg/commands/secret/create.go and shows the incorrect certificate key. Read the TLS secret creation code and check for related tests for kn secret create. Change the certificate key to Kubernetes’ expected tls.crt; done means the secret contains tls.crt and tls.key and the command succeeds against the API server.

Written by the indexing model from the issue text.

Description

Bug report

kn secret create NAME --tls-cert CERT --tls-key KEY creates a secret of type kubernetes.io/tls, but stores the certificate under the key tls.cert. Kubernetes expects the certificate under tls.crt (corev1.TLSCertKey). The API server validates kubernetes.io/tls secrets and rejects one that has no tls.crt entry, so the command fails. Consumers such as DomainMapping TLS also read tls.crt.

The code is in pkg/commands/secret/create.go:

certData := map[string]string{
	"tls.cert": string(cerFromFile),
	"tls.key":  string(keyFromFile),
}
toCreate.Type = corev1.SecretTypeTLS
Expected behavior

The secret contains tls.crt and tls.key, the same as kubectl create secret tls.

Steps to reproduce the problem
kn secret create my-tls --tls-cert tls.crt --tls-key tls.key

The API server rejects the request with an error like data[tls.crt]: Required value.

kn version
main (5817cd7)
Knative (serving/eventing) version

Not applicable. The key name is set by kn.

Dominant language
Go
Stars
387
Forks
278
Avg merge
2d 10h
Merged PRs (30d)
8

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from knative/client

All issues in knative/client

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.