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

生成的私钥解析错误 #205

Open
blueskydata opened this issue Aug 31, 2024 · 0 comments
Open

生成的私钥解析错误 #205

blueskydata opened this issue Aug 31, 2024 · 0 comments

Comments

@blueskydata
Copy link

    priv, err := sm2.GenerateKey(nil) // 生成密钥对
if err != nil {
	fmt.Println(err)
	return
}

privPem, err := x509.WritePrivateKeyToPem(priv, []byte("1234")) // 生成密钥文件
if err != nil {
	fmt.Println(err)
	return
}

file, err := os.OpenFile("gmserver.pem", os.O_RDWR|os.O_CREATE, 0644)
if err != nil {
	fmt.Println(err)
	return
}
_, err = file.Write(privPem)
if err != nil {
	fmt.Println(err)
}
file.Close()

保存进去的私钥,为什么解析的时候就报错。

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

1 participant