如何从tls证书和密钥创建PGP密钥,并使用PGP私钥解密golang中的PGP消息?
从以下逻辑开始, (基于:RSA密钥部分对于TLS和PGP是通用的) openpgp.ReadMessage返回以下错误 openpgp:无效数据:标记字节未设置MSB如何从tls证书和密钥创建PGP密钥,并使用PGP私钥解密golang中的PGP消息?,go,Go,从以下逻辑开始, (基于:RSA密钥部分对于TLS和PGP是通用的) openpgp.ReadMessage返回以下错误 openpgp:无效数据:标记字节未设置MSB 我想我在创建实体时遗漏了一些东西。你能帮我解决这个问题吗?你有没有想到这个问题你有没有偶然发现这个问题?:) tlsCert, err := tls.LoadX509KeyPair(certFilePath, keyFilePath) if err != nil { return } certx509, _ := iou
我想我在创建实体时遗漏了一些东西。你能帮我解决这个问题吗?你有没有想到这个问题你有没有偶然发现这个问题?:)
tlsCert, err := tls.LoadX509KeyPair(certFilePath, keyFilePath)
if err != nil {
return
}
certx509, _ := ioutil.ReadFile(certFilePath)
block, _ := pem.Decode([]byte(certx509))
certTest, err := x509.ParseCertificate(block.Bytes)
if err != nil {
return
}
privateKeyTest := tlsCert.PrivateKey
config = &packet.Config{}
config.DefaultCompressionAlgo = 1
config.DefaultCipher = 9
config.DefaultHash = 3
entity, _ = openpgp.NewEntity("", "", "", config)
entity.PrimaryKey.PublicKey = (certTest.PublicKey).(*rsa.PublicKey)
entity.PrivateKey.PrivateKey = privateKeyTest.(*rsa.PrivateKey)
entitylist := make(openpgp.EntityList, 1)
entitylist[0] = entity
md, err := openpgp.ReadMessage(encryptedmessagebytes, entitylist , nil, config)