-
Notifications
You must be signed in to change notification settings - Fork 52
SSL Certificate decode error (pkcs12: expected exactly two safe bags in the PFX PDU) #8
Comments
@idyll What needs to be done to remove the duplicates from a p12 file? |
When you export the p12 from Keychain, be sure to select both the certificate and the private key. If I only select the private key, I get the following error: Does this resolve the issue for you? Reference: Installing a Client SSL Signing Identity on the Server |
I tried recreating the cert from scratch and it still logs the same error. I edited the file I checked the cert from my command line:
|
Well this is weird! I edited the and voila! Notification sent! Maybe the certificate Apple generates is not compliant with pkcs12 but I think I'll use the edited version of |
Glad to hear you found a workaround, though I'm still not sure why it was necessary. |
I forgot to mention that I had later tried to use only the public certificate (and not public cert and private key exported together as mentioned in Apple's docs) and got it to work without commenting out the safe-bags validation in |
Thanks for logging a bug with the crypto team. It's odd that I had a somewhat opposite experience #8 (comment) |
Same thing that tipycalFlow reported here. Following the Apple Guide and exporting both the cert and private key resulted in the same two bags error but exporting just the cert got past that. I noticed that a couple of the buford source files, e.g. push/client.go and certificate/cert.go, import "golang.org/x/net/http2" or "golang.org/x/crypto/pkcs12". I'd expect that the Go 1.6 release includes those packages without the "x/" part in their paths. Is that done to explicitly enable the features for older Go versions? |
There is an issue to support more than two bags for pkcs12, but I haven't had a chance to work on it yet. golang/go#14015 As to your other question, In my tests the current x/net/http2 client doesn't work with Go 1.5, so we're not importing it for that. We are pulling in Maybe API could be added to Go 1.7 to allow the equivalent of |
This still seems like it is a problem. I've been using a system that output pks12 and it has the same problem. In my case, I found that if in Decode() I:
I get what I'm looking for. In the same way Apple does, I seem to be getting 4 bags. Here's exactly what I did:
for i := 0; i < 2; i++ { I don't know enough about how PKCS12 works to understand the problem between what is in the file and this library to know what is going on. But I wanted to indicate this is a problem for other users. |
Maybe should switch to https://github.com/SSLMate/go-pkcs12? |
Same problem and same solution. Thanks to @element-of-surprise and @tipycalFlow |
if using https://github.com/SSLMate/go-pkcs12 you should be probably using the |
Hey,
I seem to have run into a certificate issue as I get the error:
pkcs12: expected exactly two safe bags in the PFX PDU
. I'm generating the Production Apple Push Notification Service SSL cert as described in Apple's docs and I had simply exported the certificate/private-key pair from my keychain to get a.p12
file and I'm using this p12 file's path as filename in linecert, err := certificate.Load(filename, password)
of the package's example. The error is returned bypkcs12
package in theDecode
method ofcert.go
and specifically, bypkcs12.Decode
. Would you happen to know why this error occurs or maybe what steps need to be taken to get the correct p12 file?The text was updated successfully, but these errors were encountered: