error reading P12 data: asn1: syntax error: indefinite length found (not DER)
eajardini opened this issue · comments
When I use:
pfxData, err := ioutil.ReadFile(p12Path)
priv, cert, err := pkc12.Decode(pfxData, "1234")
if err != nil {
log.Fatal("Fail: %v\n", err)
}
I get this error:
pkcs12: error reading P12 data: asn1: syntax error: indefinite length found (not DER)
Since pkcs12 uses Go's standard encoding/asn1 package, it means that only DER-encoded PKCS#12 files are supported. The file you are trying to read is encoded in BER. If you re-encode it in DER then this package should be able to read it.
Unfortunately this is not easy to fix but I will add a note to the documentation about the limitation.
Thank you for answering
Documentation updated in commit c9ed90b