Search code examples
javasecuritycertificatex509certificatex509certificate2

java.security.cert.CertificateParsingException


I'm getting the following exception when trying to create a new certificate:

java.security.cert.CertificateParsingException: signed overrun, bytes = 224

    try
    {
        InputStream certificateStream = new ByteArrayInputStream(certificate);
        CertificateFactory cf = CertificateFactory.getInstance("X.509");
        Collection certificateCollection = cf.generateCertificates(certificateStream);
    }
    catch (CertificateException ex)
    {

    }

the exception is thrown in: Collection certificateCollection = cf.generateCertificates(certificateStream);

can someone help me to understand and solve this issue?

Thanks


Solution

  • Ok, my mistake.

    I read the certificate from file, and I didn't read it as binary...

    Reading as binary solved this issue.

    Thanks alot for all your answers / comments!