SilleBille / pki

Dogtag PKI Issues should be reported to the Dogtag PKI Pagure Issues site
https://pagure.io/dogtagpki/issues
GNU General Public License v2.0
1 stars 1 forks source link

zero-length OCTET STRING DerValue cannot be converted to byte[] #480

Closed SilleBille closed 4 years ago

SilleBille commented 4 years ago

This issue was migrated from Pagure Issue #3079.Originally filed by ftweedal on 2018-11-11

When reading a DerValue as an OCTET STRING via getOctetString(), if the length of the OCTET STRING is zero an exception is thrown:

java.io.IOException: short read on DerValue buffer

The following program reproduces the issue:

import java.io.IOException;
import netscape.security.util.DerValue;

class DerTest {
    public static void main(String[] args) {
        byte[] bytes = { 0x04, 0x00 };
        try {
            DerValue derVal = new DerValue(bytes);
            System.out.println(derVal.getOctetString());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
SilleBille commented 4 years ago

Posted by ftweedal on 2018-11-11:

PR: https://github.com/dogtagpki/pki/pull/103