Skip to main content
Home
for DLMS smart meters

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Error Parsing ASN1 CSR, KeyUsage Field

Error parsing ASN1 CSR, keyUsage field

By enemy235, 17 December, 2025
Project
gurux.dlms.java
Status
Closed (fixed)

There is a problem in parsing some CSR in GXAsn1Converter.java, when parsing a specific CSR (problematic CSR is added in HEX and PEM at the end).

The problem is probably in the keyUsage segment. This CSR defines the key ussage in slightly different way, but it is not incorrect way.

Usually it is defined as 03020080 10000000
but in this case uses 03020780 1 (using only 1 bit). From my understanding of ASN1, the 07 in previous segment, specifies, that last 7 bits are not used. When using other ASN1 parsers (eg. https://lapo.it/asn1js/ or openssl) it is decoded correctly there.

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 1
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.util.Objects.checkIndex(Objects.java:385)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
at gurux.dlms.asn.GXAsn1Converter.getValue(GXAsn1Converter.java:341)
at gurux.dlms.asn.GXAsn1Converter.getValue(GXAsn1Converter.java:322)
at gurux.dlms.asn.GXAsn1Converter.getValue(GXAsn1Converter.java:307)
at gurux.dlms.asn.GXAsn1Converter.getValue(GXAsn1Converter.java:322)
at gurux.dlms.asn.GXAsn1Converter.getValue(GXAsn1Converter.java:322)
at gurux.dlms.asn.GXAsn1Converter.fromByteArray(GXAsn1Converter.java:536)
at gurux.dlms.asn.GXPkcs10.init(GXPkcs10.java:167)
at gurux.dlms.asn.GXPkcs10.<init>(GXPkcs10.java:126)

I tried to fix the issue, but I think, I only suppressed the problem with this additional if statement. But there is probably problem deeper in the ASN1 convertor.

case BerType.CONSTRUCTED | BerType.SET:
if (s != null) {
s.increase();
}
tmp = new ArrayList<Object>();
getValue(bb, tmp, s, false);
if (tmp.get(0) instanceof GXAsn1Sequence) {
tmp = (GXAsn1Sequence) tmp.get(0);

//Added check here
if( tmp.size() == 2) {
objects.add(new GXSimpleEntry<Object, Object>(tmp.get(0), tmp.get(1)));
} else {
objects.add(new GXSimpleEntry<Object, Object>(tmp.get(0), null));
}

} else ...

Error will occur for this CSR:
308201333081B8020100301B3119301706035504030C1035413530343130
3033423942394238463076301006072A8648CE3D020106052B8104002203
6200043B2781FC974699C1527048F958CBD9FB4DB06B7F4088054915C8DC
49C6B84271CF2DA634908BB36C4E025B25C77F3DF86BF6116181A73ECF5E
795731BE2457090A18A6EBD012FE54D85B2796BD8D18E1C9943FA189236F
88CCD82274B8174E46A01E301C06092A864886F70D01090E310F300D300B
0603551D0F040403020780300C06082A8648CE3D04030305000368003065
023056A28854C295777D88A077B6E82C299C06CE5CDBF471E47EAD65FB0D
F1CC600E4DB71639653FCBD3277A94BFB8BCD544023100A6C182F4FC7663
6133F48D2500D750C7E081B90EFFCD79DE64781443DD9AE2B1ED68AB6FAE
FA8C16E16B230705C9DAF0

-----BEGIN CERTIFICATE REQUEST-----
MIIBMzCBuAIBADAbMRkwFwYDVQQDDBA1QTUwNDEwMDNCOUI5QjhGMHYwEAYHKoZI
zj0CAQYFK4EEACIDYgAEOyeB/JdGmcFScEj5WMvZ+02wa39AiAVJFcjcSca4QnHP
LaY0kIuzbE4CWyXHfz34a/YRYYGnPs9eeVcxviRXCQoYpuvQEv5U2Fsnlr2NGOHJ
lD+hiSNviMzYInS4F05GoB4wHAYJKoZIhvcNAQkOMQ8wDTALBgNVHQ8EBAMCB4Aw
DAYIKoZIzj0EAwMFAANoADBlAjBWoohUwpV3fYigd7boLCmcBs5c2/Rx5H6tZfsN
8cxgDk23FjllP8vTJ3qUv7i81UQCMQCmwYL0/HZjYTP0jSUA11DH4IG5Dv/Ned5k
eBRD3Zrise1oq2+u+owW4WsjBwXJ2vA=
-----END CERTIFICATE REQUEST-----

Priority
Normal
Category
Bug report
Profile picture for user Administrator

Administrator

1 month 2 weeks ago

Fixed in version 4.0.89.

Fixed in version 4.0.89.

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Thu, 02/19/2026 - 11:51
    gurux.dlms.cpp 9.0.2602.1901
  • Sun, 02/01/2026 - 19:47
    gurux.dlms.cpp 9.0.2602.0101
  • Tue, 01/20/2026 - 10:38
    gurux.dlms.java 4.0.89
  • Wed, 01/14/2026 - 14:29
    Gurux.DLMS.Python 1.0.196
  • Mon, 12/29/2025 - 10:38
    Gurux.Serial.Android 3.0.5

New forum topics

  • Help with connection and read with landis+gyr e650 + CU-E22 using python
  • Preestablished connection
  • RJ11 to RS232 Pin out SECURE Premier 300
  • GENUS sugam 3 PH bidirectional
  • Electricity smart Meter DLMS firmware stack
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin