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?
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)
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.
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
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)
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.
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.
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
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
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
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
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
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
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