Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

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

Breadcrumb

  1. Home
  2. Forums
  3. Can't Import CA Cetrificate

Can't import CA Cetrificate

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By VitalyP , 21 April, 2021
Forums
Gurux.DLMS

Hi,

DLMS library throws exception if imported certificate has a BasicConstraints field with a critical flag.

Example of such Certificate:
-----BEGIN CERTIFICATE-----
MIIBlzCCAT2gAwIBAgIJAMpe+tZzflJHMAoGCCqGSM49BAMCMBIxEDAOBgNVBAMM
B1Jvb3QtQ0EwHhcNMjAwMjAzMTA0MzA1WhcNMjEwMjAyMTA0MzA1WjAYMRYwFAYD
VQQDDA1FTkVSR09NRVJBLUNBMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEPhVo
mqevnKuzyDAs49FcPpxJDUPVmpO07RQ2NL4TcgMX4VqaJ73rmgY05b0cGbn/LtA/
YtX81QKJ1UvgRkMWZ6N2MHQwHwYDVR0jBBgwFoAU1RVzQOf66nzqIoqgTOEIO19j
tSMwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUrOs0o+LBjXAn51YHHgT5FV0N
rB0wDgYDVR0PAQH/BAQDAgIEMBEGA1UdIAQKMAgwBgYEVR0gADAKBggqhkjOPQQD
AgNIADBFAiBlkpiaa1kZi0UPXM88dugiVFLnu+r10Cy2xUsfs9nnkQIhALbBjtkG
xlqfBY431tV1INKI1c855eBGJvgeusvMl69G
-----END CERTIFICATE-----

regards,
Vitaly

Profile picture for user Kurumi

Kurumi

5 years 3 months ago

Hi Vitaly,

Hi Vitaly,

BasicConstraints should be inside of a sequence, but this certificate uses it without sequence and that is breaking it. You can find more information from BasicConstraints here:
https://tools.ietf.org/html/rfc5280

BR
Mikko

VitalyP

5 years 3 months ago

Hi, Mikko

Hi, Mikko

This is valid certificate, generated with openSSL.

You are right, BasicConstraints itself is a sequence, but this sequence is inside another "extension" sequence.

Extension ::= SEQUENCE {
extnID OBJECT IDENTIFIER,
critical BOOLEAN DEFAULT FALSE,
extnValue OCTET STRING
-- contains the DER encoding of an ASN.1 value
-- corresponding to the extension type identified
-- by extnID
}

If "critical" flag is absent (default), BasicConstraints sequence follow extnID immideately.
But if "critical" flag presents it included before BasicConstraints sequence.

DLMS library doesn't check if critical flag presents. And try to parse next field as sequence.

The same rule applies to KeyUsage field. And this field DLMS handle correctly.

Regards,
Vitaly

Profile picture for user Kurumi

Kurumi

5 years 3 months ago

Hi,

Hi,

This is tested and validated also with OpenSSL. BasicConstraint is inside of Sequence as I told.

I have made an introduction to how to generate a custom certificate with OpenSSL.
http://gurux.fi/CustomCertificate

I hope it helps you.

BR,
Mikko

VitalyP

5 years 3 months ago

Hi, Mikko

Hi, Mikko

Your description is not correct.
In ca.ext file you need to have a string:

basicConstraints=critical, CA:TRUE
In accordance to DLMS green book basicConstraints must set it's "Critical" flag to TRUE.
The same for the KeyUsage.

regards,
Vitaly

Profile picture for user Kurumi

Kurumi

5 years 3 months ago

Hi Vitaly,

Hi Vitaly,

You are right on this and thank you for pointing this out. The critical flag was missing. This is now fixed and the new version is released on Monday.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Mon, 07/27/2026 - 12:37
    gurux.dlms.cpp 9.0.2607.2701
  • Thu, 07/23/2026 - 16:19
    gurux.dlms.java 4.0.96
  • Thu, 07/09/2026 - 14:34
    Gurux.DLMS.Python 1.0.201
  • Fri, 06/26/2026 - 16:32
    Gurux.Service 3.0.2606.2601
  • Wed, 06/24/2026 - 08:36
    Gurux.DLMS.Python 1.0.200

New forum topics

  • Service not known error on gprs communication
  • Help Needed: Interfacing Saral 100 Energy Meter with Microcontroller via RS232
  • Connecting Meter to Agent via serial
  • Reading block profile with Compact array
  • DLMS server - serving multiple similar datasets gathered from multiple meters across distinct logical addresses
More

Who's new

  • Vital479
  • HealthPro16
  • Brandondiz
  • JeffreyPal
  • DingfanXue
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin