eclipse / milo

Eclipse Milo™ - an open source implementation of OPC UA (IEC 62541).
http://www.eclipse.org/milo
Eclipse Public License 2.0
1.14k stars 424 forks source link

java.security.InvalidKeyException: Illegal key size While running client-examples/ReadExample #875

Closed xamry closed 3 years ago

xamry commented 3 years ago

I imported the milo-master maven project in eclipse on my Windows machine. There are no compilation errors. I have also built it with maven. Now when I try to run the ReadExample to begin with, it throws below error:

00:11:29,427 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy] 00:11:29,427 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml] 00:11:29,427 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/D:/milo-code/milo-master/milo-examples/client-examples/target/classes/logback.xml] 00:11:29,428 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs multiple times on the classpath. 00:11:29,428 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [file:/D:/milo-code/milo-master/milo-examples/client-examples/target/classes/logback.xml] 00:11:29,428 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [file:/D:/milo-code/milo-master/milo-examples/server-examples/target/classes/logback.xml] 00:11:29,706 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set 00:11:29,751 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender] 00:11:29,754 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT] 00:11:29,856 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - This appender no longer admits a layout as a sub-component, set an encoder instead. 00:11:29,856 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder. 00:11:29,856 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details 00:11:29,857 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO 00:11:29,857 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT] 00:11:29,858 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration. 00:11:29,859 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@46f5f779 - Registering current configuration as safe fallback point

00:11:30.684 [milo-nonce-util-secure-random] INFO o.e.m.o.stack.core.util.NonceUtil - SecureRandom seeded in 334ms. 00:11:30.691 [main] INFO o.e.m.examples.server.ExampleServer - security dir: C:\Users\AMRESH~1.SIN\AppData\Local\Temp\server\security 00:11:30.691 [main] INFO o.e.m.examples.server.ExampleServer - security pki dir: C:\Users\AMRESH~1.SIN\AppData\Local\Temp\server\security\pki 00:11:30.694 [main] INFO o.e.m.examples.server.KeyStoreLoader - Loading KeyStore at C:\Users\AMRESH~1.SIN\AppData\Local\Temp\server\security\example-server.pfx 00:11:50.343 [main] INFO o.e.m.opcua.sdk.server.OpcUaServer - Eclipse Milo OPC UA Stack version: 0.6.4-SNAPSHOT 00:11:50.344 [main] INFO o.e.m.opcua.sdk.server.OpcUaServer - Eclipse Milo OPC UA Server SDK version: 0.6.4-SNAPSHOT 00:11:52.140 [main] INFO o.e.m.o.s.s.n.OpcUaNamespace - Loaded 2004 nodes in 768ms. 00:11:52.362 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://:12686/milo to 0.0.0.0:12686 [None/None] 00:11:53.180 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://:12686/milo to 0.0.0.0:12686 [Basic256Sha256/SignAndEncrypt] 00:11:53.181 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://:12686/milo/discovery to 0.0.0.0:12686 [None/None] 00:11:53.181 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://10.212.135.208:12686/milo to 0.0.0.0:12686 [None/None] 00:11:53.181 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://10.212.135.208:12686/milo to 0.0.0.0:12686 [Basic256Sha256/SignAndEncrypt] 00:11:53.181 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://10.212.135.208:12686/milo/discovery to 0.0.0.0:12686 [None/None] 00:11:53.181 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://192.168.56.1:12686/milo to 0.0.0.0:12686 [None/None] 00:11:53.181 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://192.168.56.1:12686/milo to 0.0.0.0:12686 [Basic256Sha256/SignAndEncrypt] 00:11:53.182 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://192.168.56.1:12686/milo/discovery to 0.0.0.0:12686 [None/None] 00:11:53.182 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://.****:12686/milo to 0.0.0.0:12686 [None/None] 00:11:53.182 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://*.****:12686/milo to 0.0.0.0:12686 [Basic256Sha256/SignAndEncrypt] 00:11:53.182 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://*.****:12686/milo/discovery to 0.0.0.0:12686 [None/None] 00:11:53.182 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://****:12686/milo to 0.0.0.0:12686 [None/None] 00:11:53.182 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://****:12686/milo to 0.0.0.0:12686 [Basic256Sha256/SignAndEncrypt] 00:11:53.182 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://****:12686/milo/discovery to 0.0.0.0:12686 [None/None] 00:11:53.182 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://192.168.1.5:12686/milo to 0.0.0.0:12686 [None/None] 00:11:53.182 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://192.168.1.5:12686/milo to 0.0.0.0:12686 [Basic256Sha256/SignAndEncrypt] 00:11:53.182 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://192.168.1.5:12686/milo/discovery to 0.0.0.0:12686 [None/None] 00:11:53.182 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://127.0.0.1:12686/milo to 0.0.0.0:12686 [None/None] 00:11:53.183 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://127.0.0.1:12686/milo to 0.0.0.0:12686 [Basic256Sha256/SignAndEncrypt] 00:11:53.183 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint opc.tcp://127.0.0.1:12686/milo/discovery to 0.0.0.0:12686 [None/None] 00:11:53.183 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://***********:8443/milo to 0.0.0.0:8443 [None/None] 00:11:53.185 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://***********:8443/milo to 0.0.0.0:8443 [Basic256Sha256/Sign] 00:11:53.185 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://***********:8443/milo/discovery to 0.0.0.0:8443 [None/None] 00:11:53.185 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://10.212.135.208:8443/milo to 0.0.0.0:8443 [None/None] 00:11:53.185 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://10.212.135.208:8443/milo to 0.0.0.0:8443 [Basic256Sha256/Sign] 00:11:53.185 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://10.212.135.208:8443/milo/discovery to 0.0.0.0:8443 [None/None] 00:11:53.185 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://192.168.56.1:8443/milo to 0.0.0.0:8443 [None/None] 00:11:53.185 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://192.168.56.1:8443/milo to 0.0.0.0:8443 [Basic256Sha256/Sign] 00:11:53.185 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://192.168.56.1:8443/milo/discovery to 0.0.0.0:8443 [None/None] 00:11:53.185 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://***********.****************:8443/milo to 0.0.0.0:8443 [None/None] 00:11:53.185 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://***********.****************:8443/milo to 0.0.0.0:8443 [Basic256Sha256/Sign] 00:11:53.185 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://***********.****************:8443/milo/discovery to 0.0.0.0:8443 [None/None] 00:11:53.186 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://****************:8443/milo to 0.0.0.0:8443 [None/None] 00:11:53.186 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://****************:8443/milo to 0.0.0.0:8443 [Basic256Sha256/Sign] 00:11:53.186 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://****************:8443/milo/discovery to 0.0.0.0:8443 [None/None] 00:11:53.186 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://192.168.1.5:8443/milo to 0.0.0.0:8443 [None/None] 00:11:53.186 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://192.168.1.5:8443/milo to 0.0.0.0:8443 [Basic256Sha256/Sign] 00:11:53.186 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://192.168.1.5:8443/milo/discovery to 0.0.0.0:8443 [None/None] 00:11:53.186 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://127.0.0.1:8443/milo to 0.0.0.0:8443 [None/None] 00:11:53.186 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://127.0.0.1:8443/milo to 0.0.0.0:8443 [Basic256Sha256/Sign] 00:11:53.187 [main] INFO o.e.m.o.stack.server.UaStackServer - Binding endpoint https://127.0.0.1:8443/milo/discovery to 0.0.0.0:8443 [None/None] 00:11:53.255 [main] INFO o.e.m.e.client.ClientExampleRunner - security dir: C:\Users\AMRESH~1.SIN\AppData\Local\Temp\client\security 00:11:53.256 [main] INFO o.e.m.e.client.ClientExampleRunner - security pki dir: C:\Users\AMRESH~1.SIN\AppData\Local\Temp\client\security\pki 00:11:53.257 [main] INFO o.e.m.examples.client.KeyStoreLoader - Loading KeyStore at C:\Users\AMRESH~1.SIN\AppData\Local\Temp\client\security\example-client.pfx 00:11:53.283 [main] INFO o.e.m.opcua.sdk.client.OpcUaClient - Eclipse Milo OPC UA Stack version: 0.6.4-SNAPSHOT 00:11:53.283 [main] INFO o.e.m.opcua.sdk.client.OpcUaClient - Eclipse Milo OPC UA Client SDK version: 0.6.4-SNAPSHOT 00:11:54.394 [milo-shared-thread-pool-1] ERROR o.e.m.o.s.c.t.u.UascClientMessageHandler - Error encoding org.eclipse.milo.opcua.stack.core.types.structured.CreateSessionRequest@3f04110d: UaException: status=Bad_SecurityChecksFailed, message=java.security.InvalidKeyException: Illegal key size org.eclipse.milo.opcua.stack.core.channel.MessageEncodeException: UaException: status=Bad_SecurityChecksFailed, message=java.security.InvalidKeyException: Illegal key size at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder.encode(ChunkEncoder.java:89) at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder.encodeSymmetric(ChunkEncoder.java:71) at org.eclipse.milo.opcua.stack.client.transport.uasc.UascClientMessageHandler.lambda$10(UascClientMessageHandler.java:339) at org.eclipse.milo.opcua.stack.core.channel.SerializationQueue.lambda$0(SerializationQueue.java:52) at org.eclipse.milo.opcua.stack.core.util.ExecutionQueue$Task.run(ExecutionQueue.java:119) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: org.eclipse.milo.opcua.stack.core.UaException: java.security.InvalidKeyException: Illegal key size at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder$SymmetricEncoder.initCipher(ChunkEncoder.java:466) at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder$SymmetricEncoder.encodeSecurityHeader(ChunkEncoder.java:392) at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder$AbstractEncoder.encode(ChunkEncoder.java:164) at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder.encode(ChunkEncoder.java:85) ... 7 common frames omitted Caused by: java.security.InvalidKeyException: Illegal key size at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1039) at javax.crypto.Cipher.implInit(Cipher.java:805) at javax.crypto.Cipher.chooseProvider(Cipher.java:864) at javax.crypto.Cipher.init(Cipher.java:1396) at javax.crypto.Cipher.init(Cipher.java:1327) at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder$SymmetricEncoder.initCipher(ChunkEncoder.java:460) ... 10 common frames omitted 00:11:54.396 [main] ERROR o.e.m.e.client.ClientExampleRunner - Error running client example: org.eclipse.milo.opcua.stack.core.channel.MessageEncodeException: UaException: status=Bad_SecurityChecksFailed, message=java.security.InvalidKeyException: Illegal key size java.util.concurrent.ExecutionException: org.eclipse.milo.opcua.stack.core.channel.MessageEncodeException: UaException: status=Bad_SecurityChecksFailed, message=java.security.InvalidKeyException: Illegal key size at java.util.concurrent.CompletableFuture.reportGet(Unknown Source) at java.util.concurrent.CompletableFuture.get(Unknown Source) at org.eclipse.milo.examples.client.ReadExample.run(ReadExample.java:40) at org.eclipse.milo.examples.client.ClientExampleRunner.run(ClientExampleRunner.java:153) at org.eclipse.milo.examples.client.ReadExample.main(ReadExample.java:32) Caused by: org.eclipse.milo.opcua.stack.core.channel.MessageEncodeException: UaException: status=Bad_SecurityChecksFailed, message=java.security.InvalidKeyException: Illegal key size at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder.encode(ChunkEncoder.java:89) at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder.encodeSymmetric(ChunkEncoder.java:71) at org.eclipse.milo.opcua.stack.client.transport.uasc.UascClientMessageHandler.lambda$10(UascClientMessageHandler.java:339) at org.eclipse.milo.opcua.stack.core.channel.SerializationQueue.lambda$0(SerializationQueue.java:52) at org.eclipse.milo.opcua.stack.core.util.ExecutionQueue$Task.run(ExecutionQueue.java:119) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: org.eclipse.milo.opcua.stack.core.UaException: java.security.InvalidKeyException: Illegal key size at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder$SymmetricEncoder.initCipher(ChunkEncoder.java:466) at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder$SymmetricEncoder.encodeSecurityHeader(ChunkEncoder.java:392) at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder$AbstractEncoder.encode(ChunkEncoder.java:164) at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder.encode(ChunkEncoder.java:85) ... 7 common frames omitted Caused by: java.security.InvalidKeyException: Illegal key size at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1039) at javax.crypto.Cipher.implInit(Cipher.java:805) at javax.crypto.Cipher.chooseProvider(Cipher.java:864) at javax.crypto.Cipher.init(Cipher.java:1396) at javax.crypto.Cipher.init(Cipher.java:1327) at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder$SymmetricEncoder.initCipher(ChunkEncoder.java:460) ... 10 common frames omitted 00:11:54.399 [ForkJoinPool.commonPool-worker-1] ERROR o.e.m.e.client.ClientExampleRunner - Error running example: org.eclipse.milo.opcua.stack.core.channel.MessageEncodeException: UaException: status=Bad_SecurityChecksFailed, message=java.security.InvalidKeyException: Illegal key size java.util.concurrent.ExecutionException: org.eclipse.milo.opcua.stack.core.channel.MessageEncodeException: UaException: status=Bad_SecurityChecksFailed, message=java.security.InvalidKeyException: Illegal key size at java.util.concurrent.CompletableFuture.reportGet(Unknown Source) at java.util.concurrent.CompletableFuture.get(Unknown Source) at org.eclipse.milo.examples.client.ReadExample.run(ReadExample.java:40) at org.eclipse.milo.examples.client.ClientExampleRunner.run(ClientExampleRunner.java:153) at org.eclipse.milo.examples.client.ReadExample.main(ReadExample.java:32) Caused by: org.eclipse.milo.opcua.stack.core.channel.MessageEncodeException: UaException: status=Bad_SecurityChecksFailed, message=java.security.InvalidKeyException: Illegal key size at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder.encode(ChunkEncoder.java:89) at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder.encodeSymmetric(ChunkEncoder.java:71) at org.eclipse.milo.opcua.stack.client.transport.uasc.UascClientMessageHandler.lambda$10(UascClientMessageHandler.java:339) at org.eclipse.milo.opcua.stack.core.channel.SerializationQueue.lambda$0(SerializationQueue.java:52) at org.eclipse.milo.opcua.stack.core.util.ExecutionQueue$Task.run(ExecutionQueue.java:119) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: org.eclipse.milo.opcua.stack.core.UaException: java.security.InvalidKeyException: Illegal key size at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder$SymmetricEncoder.initCipher(ChunkEncoder.java:466) at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder$SymmetricEncoder.encodeSecurityHeader(ChunkEncoder.java:392) at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder$AbstractEncoder.encode(ChunkEncoder.java:164) at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder.encode(ChunkEncoder.java:85) ... 7 common frames omitted Caused by: java.security.InvalidKeyException: Illegal key size at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1039) at javax.crypto.Cipher.implInit(Cipher.java:805) at javax.crypto.Cipher.chooseProvider(Cipher.java:864) at javax.crypto.Cipher.init(Cipher.java:1396) at javax.crypto.Cipher.init(Cipher.java:1327) at org.eclipse.milo.opcua.stack.core.channel.ChunkEncoder$SymmetricEncoder.initCipher(ChunkEncoder.java:460) ... 10 common frames omitted

Additional context Eclipse Milo Version: 0.6.3 Windows 10 Java 8

kevinherron commented 3 years ago

I'm guessing you are running a version of Java 8 that is < 8u162, which means you aren't allowed to use 256-bit encryption without installing the JCE unlimited crypto policy files.

Easiest thing to do would be to use 8u162+, which no longer requires this: https://bugs.openjdk.java.net/browse/JDK-8170157

xamry commented 3 years ago

Thanks @kevinherron . This solved my issue.