PEMReader incorrectly reads some Certificate Signing Requests

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

PEMReader incorrectly reads some Certificate Signing Requests

Lukasz Kowalczyk
There is a minor bug in PEMReader which causes a ClassCastException
when reading a CSR which starts with "BEGIN CERTIFICATE REQUEST"
instead of "BEGIN NEW CERTIFICATE REQUEST".

In the readObject() method the line which tests for BEGIN CERTIFICATE
REQUEST should come before the line that checks for BEGIN CERTIFICATE.

Patch for release 128 is enclosed below:

--- PEMReader.java 2005-03-18 10:06:46.000000000 +0100
+++ PEMReader.java.patched 2005-06-09 12:59:53.937500000 +0200
@@ -109,6 +109,10 @@
             {
                 return readRSAPublicKey("-----END RSA PUBLIC KEY");
             }
+            if (line.indexOf("-----BEGIN CERTIFICATE REQUEST") != -1)
+            {
+                return readCertificateRequest("-----END CERTIFICATE REQUEST");
+            }
             if (line.indexOf("-----BEGIN CERTIFICATE") != -1)
             {
                 return readCertificate("-----END CERTIFICATE");
@@ -125,10 +129,6 @@
             {
                 return readAttributeCertificate("-----END ATTRIBUTE
CERTIFICATE");
             }
-            if (line.indexOf("-----BEGIN CERTIFICATE REQUEST") != -1)
-            {
-                return readCertificateRequest("-----END CERTIFICATE REQUEST");
-            }
             if (line.indexOf("-----BEGIN NEW CERTIFICATE REQUEST") != -1)
             {
                 return readCertificateRequest("-----END NEW
CERTIFICATE REQUEST");


--
Ɓukasz Kowalczyk