<p>Has anyone successfully used the "golang.org/x/crypto/pkcs12" sub-repository to successfully decode a pkcs#12 file?</p>
<p>I've been experimenting using golang and openssl and can't get the golang pkcs12.Decode() to interoperate with openssl pkcs#12 encoding - it fails complaining there are more than two (3) safe bags in the data.</p>
<p>Has anyone successfully been able to use the Decode() function?</p>
<pre><code> pfxData, err := ioutil.ReadFile("final_result.pfx")
if err != nil {
fmt.Printf("failed to read file: %s\n", err)
os.Exit(1)
}
// Attempt to Decode the file:
// func Decode(pfxData []byte, password string) (privateKey interface{}, certificate *x509.Certificate, err error)
_, _, err = pkcs_spc.Decode(pfxData, "foobar")
if err != nil {
fmt.Printf("Decode failed: %s\n", err)
os.Exit(1)
}
</code></pre>
<hr/>**评论:**<br/><br/>nyoungman: <pre><p>Hi,
There is an open issue to allow decoding of multiple certificates: <a href="https://github.com/golang/go/issues/14015" rel="nofollow">https://github.com/golang/go/issues/14015</a></p>
<p>I intend to prepare a CL in the coming week. For the moment you could try using the ToPEM API.</p></pre>
