You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When exporting a certificate, Windows replaces the localKeyID bag attribute while in Linux it doesn't get replaced. Instead, another localKeyID attribute is added to the same bag but with a different value.
This is a problem when trying to load the exported certificate using BouncyCastle's Pkcs12Store.Load().
The following console app demonstrates the problem:
The linux certificate is then not usable in BouncyCastle:
var rawData = File.ReadAllBytes(@"C:\work\exported-in-linux.pfx");
var store = new Pkcs12Store();
store.Load(new MemoryStream(rawData), Array.Empty<char>());
We get the exception
System.IO.IOException: attempt to add existing attribute with different value
at Org.BouncyCastle.Pkcs.Pkcs12Store.Load(Stream input, Char[] password)
at ConsoleApp3.Program.Main(String[] args) in /home/iftah/Program.cs:line 21
In the zip you can find all three certificates used here:
original.pfx
exported-in-linux.pfx
exported-in-windows.pfx certs.zip
The text was updated successfully, but these errors were encountered:
Seems strange that the key id is actually changing, since I was under the impression that OpenSSL used the cert thumbprint as the key id.
Since we opaquely use PKCS12_parse and PKCS12_create this is probably best addressed by breaking up with those functions, which is on the near-ish-term list anyways, to solve things like the multiple-private-key export.
When reading such certificate in java using default security provider, it doesn't load public key. When I use bouncy castle then I get:
java.io.IOException: attempt to add existing attribute with different value
at org.bouncycastle.jcajce.provider.keystore.pkcs12.PKCS12KeyStoreSpi.engineLoad(Unknown Source)
at java.base/java.security.KeyStore.load(KeyStore.java:1479)
Running on Ubuntu 16.04.
When exporting a certificate, Windows replaces the localKeyID bag attribute while in Linux it doesn't get replaced. Instead, another localKeyID attribute is added to the same bag but with a different value.
This is a problem when trying to load the exported certificate using BouncyCastle's Pkcs12Store.Load().
The following console app demonstrates the problem:
Output:
And if we export the same certificate in windows we get:
The linux certificate is then not usable in BouncyCastle:
We get the exception
In the zip you can find all three certificates used here:
original.pfx
exported-in-linux.pfx
exported-in-windows.pfx
certs.zip
The text was updated successfully, but these errors were encountered: