【发布时间】:2021-08-31 20:40:12
【问题描述】:
问题
我用secp256k1生成了密钥和证书,运行rke v1.2.8版本,得到如下错误:
FATA[0000] Failed to read certificates from dir [/home/max/cluster_certs]: failed to read certificate [kube-apiserver-requestheader-ca.pem]: x509: unsupported elliptic curve
kubectl version:
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.1", GitCommit:"5e58841cce77d4bc13713ad2b91fa0d961e69192", GitTreeState:"clean", BuildDate:"2021-05-12T14:18:45Z", GoVersion:"go1.16.4", Compiler:"gc", Platform:"linux/amd64"}
我通过以下方式生成了根 CA 密钥和证书:
openssl ecparam -name secp256k1 -genkey -noout -out ca-pvt.pem -rand random.bin -writerand random.bin
openssl req -config .\openssl.cnf -x509 -sha256 -new -nodes -key ca-pvt.pem -days 10227 -out ca-cert.cer -rand random.bin -writerand random.bin
然后我用它来签署由我的 Kubernetes Rancher cluster.yml 中的 rke cert generate-csr 生成的 CSR。
批准 CSR 的命令行如下:
openssl ca -config openssl.cnf -batch -in %1 -out %2 -create_serial -notext -rand random.bin -writerand random.bin
问题
如果secp256k1 产生x509: unsupported elliptic curve 错误消息,Kubernetes 目前支持哪些曲线用于证书?
附言
我也试过prime256v1,也称为secp256r1。与secp256k1 相比,它进一步发展,但仍然出现错误。
有了prime256v1,RKE 没有抱怨x509: unsupported elliptic curve。
相反,它给出了错误panic: interface conversion: interface {} is *ecdsa.PrivateKey, not *rsa.PrivateKey。以下是完整的错误信息:
这是完整的错误信息:
DEBU[0000] Certificate file [./cluster_certs/kube-apiserver-requestheader-ca.pem] content is greater than 0
panic: interface conversion: interface {} is *ecdsa.PrivateKey, not *rsa.PrivateKey
goroutine 1 [running]: github.com/rancher/rke/pki.getKeyFromFile(0x7ffe6294c74e, 0xf, 0xc00105cb10, 0x27, 0x8, 0xc00105cb10, 0x27)
/go/src/github.com/rancher/rke/pki/util.go:656 +0x212
【问题讨论】:
-
嗨@MaximMasiutin,您是否尝试将您的曲线更改为
secp256r1?主要区别在于secp256k1是 Koblitz 曲线,而secp256r1不是。众所周知,Koblitz 曲线比其他曲线弱一些。 -
你也可以试试曲线
prime256v1 -
@MikołajGłodziak - 你是对的,如果我指定“secp256r1”,OpenSSL 会给出以下消息:
using curve name prime256v1 instead of secp256r1。 OpenSSL 支持“secp256r1”,它只是称为“prime256v1”。查看 RFC 5480 中的第 2.1.1.1 节,其中“secp192r1”曲线称为“prime192v1”,“secp256r1”曲线称为“prime256v1”。 -
您的问题现在解决了吗?
-
我已经安装了一个带有RSA的集群,所以我现在需要设置一个测试环境来测试EC曲线(ECDSA)而不是RSA,以便更快地运行。我会尽快通知你。
标签: kubernetes rancher elliptic-curve rancher-rke