Go 如何将*x509.Certificate转换为字节数组
你好,我有这样的东西要读。p12密钥库Go 如何将*x509.Certificate转换为字节数组,go,cryptography,Go,Cryptography,你好,我有这样的东西要读。p12密钥库 func read_keys()(interface{},*x509.Certificate) { b, err:= ioutil.ReadFile("mystore.p12") if err!=nil { fmt.Println(err) return nil,nil } password := "pass" privk, pKey , err := pkcs12.Decode(b,
func read_keys()(interface{},*x509.Certificate) {
b, err:= ioutil.ReadFile("mystore.p12")
if err!=nil {
fmt.Println(err)
return nil,nil
}
password := "pass"
privk, pKey , err := pkcs12.Decode(b,password)
if err!=nil {
fmt.Println(err)
}
return privk,pKey
}
现在我需要将pKey更改为AES.cipher的字节数组,我不知道我在pkcs12和pem文档中是如何查找的,并尝试了一些解码函数,但它不起作用。有没有办法这样读取AES密钥?因为这段代码会抛出“只支持RSA和ECDSA公钥”的错误,我也需要从密钥库读取AES密钥
提前感谢请查看下面的代码片段
derPubKey, err := x509.MarshalPKIXPublicKey(&pKey.PublicKey)
if err != nil {
//handle error here
}
pubBytes := pem.EncodeToMemory(&pem.Block{
Type: "RSA PUBLIC KEY",
Bytes: derPubKey,
})
ioutil.WriteFile("key.pub", pubBytes, 0644)
“它不工作”不是一个适当的问题描述。展示你所做的尝试以及为什么它不能解决你的问题。