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

Unable to create admin client cert and private key #457

Closed
windowsrefund opened this issue Apr 2, 2019 · 12 comments
Closed

Unable to create admin client cert and private key #457

windowsrefund opened this issue Apr 2, 2019 · 12 comments

Comments

@windowsrefund
Copy link

Both ca.pem and ca-key.pem exist (previous step worked as expected).

admin-csr.json
{ "CN": "admin", "key": { "algo": "rsa", "size": 2048 }, "names": [ { "C": "US", "L": "Portland", "O": "system:masters", "OU": "Kubernetes The Hard Way", "ST": "Oregon" } ] }

Try to generate...

$ cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=kubernetes admin-csr.json | cfssljson -bare admin 2019/04/02 14:12:37 [INFO] generate received request 2019/04/02 14:12:37 [INFO] received CSR 2019/04/02 14:12:37 [INFO] generating key: rsa-2048 2019/04/02 14:12:37 [INFO] encoded CSR {"code":5100,"message":"Invalid policy: no key usage available"} Failed to parse input: unexpected end of JSON input

@alexanelli
Copy link

alexanelli commented Apr 10, 2019

having this same issue. On mac os mojave 10.14.3 using cfssl version 1.3.2

edit: fixed this by running the command in the same directory as my ca.pem and ca-key.pem ( I was running the command in a different directory before realizing that this command referenced the other files

@windowsrefund
Copy link
Author

windowsrefund commented Apr 12, 2019

Thank you for the feedback. Strange that I can't reproduce as I'm running the command from my home directory which contains both ca.pem and ca-key.pem. Seems the error is being generated from cfssl as I removed the pipe in order to isolate where the problem is coming from. I'll take a step back and regenerate the ca.pem and ca-key.pem files just to see what I see and will report back after attempting to generate the admin bits...

Same error

{"code":5100,"message":"Invalid policy: no key usage available"}

@windowsrefund
Copy link
Author

Closing this as I just discovered I'm using cfssl 1.2 as that's the latest package. I'll upgrade manually.

@windowsrefund
Copy link
Author

Reopening after being able to reproduce the same error using cfsssl 1.3.3

@windowsrefund windowsrefund reopened this Apr 12, 2019
@ghost
Copy link

ghost commented Aug 6, 2019

same error with cfssl 1.2

@singhvivek2503
Copy link

For me ca-config.json file wasn't well formed. I formatted the json and it worked!

@penghon
Copy link

penghon commented Sep 13, 2019

Missing profile -profile=kubernetes in cfssl? Fall back to default does not contain any key usage configuration hence "no key usage available"?

@kelseyhightower
Copy link
Owner

This issues seems resolved.

@skydiy
Copy link

skydiy commented Jul 29, 2020

Both ca.pem and ca-key.pem exist (previous step worked as expected).

admin-csr.json
{ "CN": "admin", "key": { "algo": "rsa", "size": 2048 }, "names": [ { "C": "US", "L": "Portland", "O": "system:masters", "OU": "Kubernetes The Hard Way", "ST": "Oregon" } ] }

Try to generate...

$ cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=kubernetes admin-csr.json | cfssljson -bare admin 2019/04/02 14:12:37 [INFO] generate received request 2019/04/02 14:12:37 [INFO] received CSR 2019/04/02 14:12:37 [INFO] generating key: rsa-2048 2019/04/02 14:12:37 [INFO] encoded CSR {"code":5100,"message":"Invalid policy: no key usage available"} Failed to parse input: unexpected end of JSON input

I have also encountered this problem!

The solution is:

In CA- config.json Define the corresponding kubernetes configuration item,

For example:

"profiles": {

"kubernetes": {

"expiry": "876000h",

"usages": [

"signing",

"key encipherment",

"server auth",

"client auth"

]

}

}

When generating the certificate, we need to pay attention to the parameter - profile = kubernetes, whether it is consistent here!

I also looked up for a long time also did not find, finally in reading ca- config.json The file process found that the configuration item name is inconsistent!

Good luck with coding! A programmer from China

@desinole
Copy link

desinole commented Mar 3, 2021

I know this issue is closed but just wanted to mention that whoever is following the tutorial should pay close attention to the "profile" field while generating the certs. Whatever the name of the profile in this section of code ("kubernetes" in below instance) should be maintained throughout

"profiles": { "kubernetes": { "usages": ["signing", "key encipherment", "server auth", "client auth"], "expiry": "8760h" } }

@tirelibirefe
Copy link

For me ca-config.json file wasn't well formed. I formatted the json and it worked!

maybe your share well formatted json?

@sakurai-youhei
Copy link

#457 (comment) saved me. Correcting a typo from usage to usages in the profiles fixes unexpected end of JSON input. :)

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

No branches or pull requests

9 participants