I’m trying to open a p7b file and read the CA certificates out of it. Below is my code. It works fine in one machine but in another machine the call to certFactory.generateCertificate throws exception
Error Message:java.lang.IllegalArgumentException: sequence wrong size for a certificate
On both machines I have the same p7b file, and the same bouncycastle jars. The machine where is works is a Windows Xp and the one where it doesn’t work is a Windows 2007 server machine. It is a 64 bit machine but I’m using the 32 bit jvm only.
Someone please help before I shoot myself.
Joined: Oct 22, 2007
I tried to upload the screenshot from Eclipse debugging session for the CertificateFactory object and the X509CertificateObject read from the p7b file, but it is not getting uploaded, so here is what it had. The values looked similar in both the working and non-working setups.
Exception in thread "main" java.security.cert.CertificateException: java.lang.IllegalArgumentException: sequence wrong size for a certificate
at org.bouncycastle.jce.provider.JDKX509CertificateFactory.engineGenerateCertificate(Unknown Source)
Caused by: java.lang.IllegalArgumentException: sequence wrong size for a certificate
at org.bouncycastle.asn1.x509.X509CertificateStructure.<init>(Unknown Source)
at org.bouncycastle.asn1.x509.X509CertificateStructure.getInstance(Unknown Source)
at org.bouncycastle.jce.provider.JDKX509CertificateFactory.readPEMCertificate(Unknown Source)
I have the unlimited strength policy jars present.
Volume in drive C has no label.
Volume Serial Number is D214-CB94
Directory of C:\jdk1.5.0_14\jre\lib\security
09/13/2004 04:12 PM 2,486 local_policy.jar
09/13/2004 04:12 PM 2,472 US_export_policy.jar
What’s wrong with this machine? If it helps, it is a 64 bit machine but the java I’m using is 32 bit.
Joined: Oct 22, 2007
Goddammit, the p7b file was actually found to be different on both the machines, I had missed it before by oversight.
However the p7b file on the problematic machine is openable by doubleclicking it and I'm able to view the certificate in it. I'm pasting the file contents below, as this website doesn't allow file with any extension at all to be uploaded. Can anyone tell me why it can't be read using the Java Apis, before I shoot myself?