I'm looking for fixing my code in order to get a .p7m file content as I do running a simple bash command:
openssl smime -decrypt -verify -inform DER -in TestDocument.pdf.p7m -noverify -out TestDocument.pdf
so I'd like to implement that with Go and found go.mozilla.org/pkcs7
package and an example as follow:
package main
import (
"io/ioutil"
"log"
"go.mozilla.org/pkcs7"
)
func main() {
content, err := ioutil.ReadFile("TestDocument.pdf.p7m")
if err != nil {
log.Fatal(err)
}
p7, err := pkcs7.Parse(content)
if err != nil {
log.Fatal(err)
}
if err := ioutil.WriteFile("TestDocument.pdf", p7.Content, 0777); err != nil {
log.Fatal(err)
}
}
and compiling it, I get this error: ber2der: Invalid BER format
.
Could you please help me to fix that?