Ai
1 Star 0 Fork 0

rio/mouse-core

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
key.go 1.78 KB
一键复制 编辑 原始数据 按行查看 历史
rio 提交于 2021-07-01 10:51 +08:00 . init
package key
import (
"gitee.com/rio-studio/mouse-core/util/key"
"github.com/spf13/cobra"
"time"
)
var (
host string
validFrom string
validFor time.Duration
isCA bool
rsaBits int
ecdsaCurve string
ed25519Key bool
savePath string
)
func init() {
KeyCmd.AddCommand(keyGenCmd)
KeyCmd.PersistentFlags().StringVarP(&host, "host", "", "", "Comma-separated hostnames and IPs to generate a certificate for")
KeyCmd.PersistentFlags().StringVarP(&validFrom, "start-date", "", "", "Creation date formatted as 2006-01-02")
KeyCmd.PersistentFlags().DurationVarP(&validFor, "duration", "", 365*24*time.Hour, "Duration that certificate is valid for")
KeyCmd.PersistentFlags().BoolVarP(&isCA, "ca", "", false, "whether this cert should be its own Certificate Authority")
KeyCmd.PersistentFlags().IntVarP(&rsaBits, "rsa-bits", "", 2048, "Size of RSA key to generate. Ignored if --ecdsa-curve is set")
KeyCmd.PersistentFlags().StringVarP(&ecdsaCurve, "ecdsa-curve", "", "", "ECDSA curve to use to generate a key. Valid values are P224, P256 (recommended), P384, P521")
KeyCmd.PersistentFlags().BoolVarP(&ed25519Key, "ed25519", "", false, "Generate an Ed25519 key")
KeyCmd.PersistentFlags().StringVarP(&savePath, "save-path", "", "./config/ssl/", "save generate key file path default: ./conf/ssl/")
}
var KeyCmd = &cobra.Command{
Use: "key",
Short: "key generator",
Long: "key generator",
}
var keyGenCmd = &cobra.Command{
Use: "gen",
Short: "key generator",
Long: "key generator",
TraverseChildren: true,
Run: func(cmd *cobra.Command, args []string) {
key.Generate(host, validFrom,
key.ValidFor(validFor),
key.IsCA(isCA),
key.RsaBits(rsaBits),
key.EcdsaCurve(ecdsaCurve),
key.Ed25519Key(ed25519Key),
key.SavePath(savePath),
)
},
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/rio-studio/mouse-core.git
git@gitee.com:rio-studio/mouse-core.git
rio-studio
mouse-core
mouse-core
v0.0.10

搜索帮助