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. How To Find Server Public Key

How to find server public key

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 NCHU DMLAB Kevin.C , 29 December, 2020
Forums
Gurux DLMS for Java

Hi,

We're trying to connect the Java server example to the conformance test tool(we want to test security suite 1), but we don't know how to find the public key of server.
Where can I find the public key of server?

Thanks
Kevin

Profile picture for user Kurumi

Kurumi

5 years 5 months ago

Hi,

Hi,

You need to create the public/private key and give the path to the private and public key with -K and -k parameters.

BR,
Mikko

NCHU DMLAB Kevin.C

5 years 5 months ago

Hi,

Hi,

We have already make public/private key by the command below:
openssl ecparam -name prime192v1 -genkey -noout -out private-key-20201230.pem
openssl ec -in private-key-20201230.pem -pubout -out public-key-20201230.pem

But we still can't give server the public/private key that we want.
What we got is:
> java -jar gurux.dlms.server.example.java/target/gurux.dlms.server.example.java-0.0.1-SNAPSHOT.jar -K private-key-20201230.pem -k public-key-20201230.pem

class [B cannot be cast to class gurux.dlms.asn.GXAsn1Sequence ([B is in module java.base of loader 'bootstrap'; gurux.dlms.asn.GXAsn1Sequence is in unnamed module of loader 'app')
Exception in thread "main" java.lang.ClassCastException: class [B cannot be cast to class gurux.dlms.asn.GXAsn1Sequence ([B is in module java.base of loader 'bootstrap'; gurux.dlms.asn.GXAsn1Sequence is in unnamed module of loader 'app')
at gurux.dlms.asn.GXPkcs8.init(GXPkcs8.java:87)
at gurux.dlms.asn.GXPkcs8.<init>(GXPkcs8.java:66)
at gurux.dlms.asn.GXPkcs8.load(GXPkcs8.java:189)
at gurux.dlms.server.example.GuruxDlmsServerExample.getParameters(GuruxDlmsServerExample.java:267)
at gurux.dlms.server.example.GuruxDlmsServerExample.main(GuruxDlmsServerExample.java:116)

Is there anything wrong with my steps?

Thanks
Kevin

Profile picture for user Kurumi

Kurumi

5 years 5 months ago

Hi,

Hi,

DLMS is using NIST curve P-256 or NIST curve P-384. You need to generate the key for them.
I don't have command line parameters for OpenSSL, but let me know if you have problems generating the keys and I can check them in next week.

BR,
Mikko

NCHU DMLAB Kevin.C

5 years 5 months ago

Hi,

Hi,

We have problems generating the keys by using openssl and some other browser key generator.
The openssl commands we use are:
openssl ecparam -name secp384r1 -genkey -noout -out private-key-20210104.pem
openssl ec -in private-key-20210104.pem -pubout -out public-key-20210104.pem

openssl ecparam -name prime256v1 -genkey -noout -out private-key-20210104.pem
openssl ec -in private-key-20210104.pem -pubout -out public-key-20210104.pem

And the website is: https://8gwifi.org/ecfunctions.jsp
We copy the keys from this website and save them as pri.pem and pub.pem. Then we give the path to the private and public key with -K and -k parameters, but we still got the same problem:
java -jar ./dlms/gurux.dlms.java/gurux.dlms.server.example.java/target/gurux.dlms.server.example.java-0.0.1-SNAPSHOT.jar -K pri.pem -k pub.pem
class [B cannot be cast to class gurux.dlms.asn.GXAsn1Sequence ([B is in module java.base of loader 'bootstrap'; gurux.dlms.asn.GXAsn1Sequence is in unnamed module of loader 'app')
Exception in thread "main" java.lang.ClassCastException: class [B cannot be cast to class gurux.dlms.asn.GXAsn1Sequence ([B is in module java.base of loader 'bootstrap'; gurux.dlms.asn.GXAsn1Sequence is in unnamed module of loader 'app')
at gurux.dlms.asn.GXPkcs8.init(GXPkcs8.java:87)
at gurux.dlms.asn.GXPkcs8.<init>(GXPkcs8.java:66)
at gurux.dlms.asn.GXPkcs8.load(GXPkcs8.java:189)
at gurux.dlms.server.example.GuruxDlmsServerExample.getParameters(GuruxDlmsServerExample.java:267)
at gurux.dlms.server.example.GuruxDlmsServerExample.main(GuruxDlmsServerExample.java:116)

Can you tell me how you generate the keys?

Thanks
Kevin

Profile picture for user Kurumi

Kurumi

5 years 5 months ago

Hi,

Hi,

The functionality is improved so you can use OpenSSL generated keys directly. This is not in testing and the new version is released at the end of this week.

BR,
Mikko

NCHU DMLAB Kevin.C

5 years 4 months ago

Hi,

Hi,

We have some problems during the keys generation. Can you teach us how you generate the keys that can be used in Java server?

Thanks
Kevin

Profile picture for user Kurumi

Kurumi

5 years 4 months ago

Hi,

Hi,

We are making some changes at the moment and the new version is released in next week so you can generate keys easily. There are several steps that must be correct or the key is not correct.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin