java - OPCUA Milo 错误,UaException : status=Bad_ConnectionRejected

标签 java eclipse security opc opc-ua

我正在尝试在 OPCUA 上运行 Milo 的独立示例。此链接:https://github.com/eclipse/milo 。创建证书并运行服务器后,客户端无法连接到他;连接被拒绝。一些忠告?谢谢。 这是来自客户端的错误日志:******************************************** **********************************

23:15:51.137 [main] INFO  o.e.m.e.c.SecureClientStandalone - Trying to load keyfile from secrets/opcua.keystore
23:15:52.012 [main] INFO  o.e.milo.opcua.stack.core.Stack - Successfully removed cryptography restrictions.
23:15:53.044 [main] INFO  o.e.m.e.c.SecureClientStandaloneRunner - URL of discovery endpoint = opc.tcp://localhost:4840/discovery
23:15:57.435 [main] INFO  o.e.m.e.c.SecureClientStandaloneRunner - Available endpoints:
23:15:57.435 [main] INFO  o.e.m.e.c.SecureClientStandaloneRunner - opc.tcp://DESKTOP-41IL17I:4840 http://opcfoundation.org/UA/SecurityPolicy#B
asic128Rsa15
23:15:57.435 [main] INFO  o.e.m.e.c.SecureClientStandaloneRunner - opc.tcp://DESKTOP-41IL17I:4840 http://opcfoundation.org/UA/SecurityPolicy#B
asic256
23:15:57.441 [main] INFO  o.e.m.e.c.SecureClientStandaloneRunner - opc.tcp://DESKTOP-41IL17I:4840 http://opcfoundation.org/UA/SecurityPolicy#B
asic256Sha256
23:15:57.443 [main] INFO  o.e.m.e.c.SecureClientStandaloneRunner - opc.tcp://DESKTOP-41IL17I:4840/discovery http://opcfoundation.org/UA/Securi
tyPolicy#None
23:15:57.443 [main] INFO  o.e.m.e.c.SecureClientStandaloneRunner - Using endpoint: opc.tcp://DESKTOP-41IL17I:4840 [http://opcfoundation.org/UA
/SecurityPolicy#Basic256Sha256, SignAndEncrypt]
23:15:57.459 [main] INFO  o.e.m.opcua.sdk.client.OpcUaClient - Eclipse Milo OPC UA Stack version: dev
23:15:57.459 [main] INFO  o.e.m.opcua.sdk.client.OpcUaClient - Eclipse Milo OPC UA Client SDK version: dev
23:15:59.412 [main] ERROR o.e.m.e.c.SecureClientStandaloneRunner - Error running client example: UaException: status=Bad_ConnectionRejected, m
essage=java.net.ConnectException: Connection refused: no further information: DESKTOP-41IL17I/192.168.1.148:4840
java.util.concurrent.ExecutionException: UaException: status=Bad_ConnectionRejected, message=java.net.ConnectException: Connection refused: no
 further information: DESKTOP-41IL17I/192.168.1.148:4840
        at java.util.concurrent.CompletableFuture.reportGet(Unknown Source)
        at java.util.concurrent.CompletableFuture.get(Unknown Source)
        at org.eclipse.milo.examples.client.SecureClientStandalone.run(SecureClientStandalone.java:105)
        at org.eclipse.milo.examples.client.SecureClientStandaloneRunner.run(SecureClientStandaloneRunner.java:150)
        at org.eclipse.milo.examples.client.SecureClientStandalone.main(SecureClientStandalone.java:49)
Caused by: org.eclipse.milo.opcua.stack.core.UaException: java.net.ConnectException: Connection refused: no further information: DESKTOP-41IL1
7I/192.168.1.148:4840
        at org.eclipse.milo.opcua.stack.client.UaTcpStackClient.lambda$bootstrap$15(UaTcpStackClient.java:510)
        at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:683)
        at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:604)
        at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:564)
        at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:425)
        at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:276)
        at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:292)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:545)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:485)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:399)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:371)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.net.ConnectException: Connection refused: no further information: DESKTOP-41IL17I/192.168.1.148:4840
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
        at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:224)
        at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:289)
        ... 6 common frames omitted

从服务器编辑日志:******************************************** **************************************************

12:34:13,407 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
12:34:13,407 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
12:34:13,407 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/C:/Users/Sal/git/repository4
prova2/miloprova2/milo-examples/standalone-examples/target/milo-certificate-server-jar-with-dependencies.jar!/logback.xml]
12:34:13,447 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@3419866c - URL [jar:file:/C:/Users/Sal/git/repository4prova2/milop
rova2/milo-examples/standalone-examples/target/milo-certificate-server-jar-with-dependencies.jar!/logback.xml] is not of type file
12:34:13,554 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
12:34:13,581 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleApp
ender]
12:34:13,584 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
12:34:13,703 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - This appender no longer admits a layout as a sub-component, set an encode
r instead.
12:34:13,703 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
12:34:13,703 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for deta
ils
12:34:13,704 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
12:34:13,704 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
12:34:13,704 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
12:34:13,706 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@63e31ee - Registering current configuration as safe fallback point

12:34:13.997 [main] INFO  o.e.milo.opcua.stack.core.Stack - Successfully removed cryptography restrictions.
12:34:14.001 [main] INFO  o.e.m.e.s.SecureServerStandalone - security temp dir: C:\Users\Sal\git\repository4prova2\miloprova2\milo-examples\st
andalone-examples\target\security
12:34:16.882 [main] INFO  o.e.m.opcua.sdk.server.OpcUaServer - Eclipse Milo OPC UA Stack version: dev
12:34:16.883 [main] INFO  o.e.m.opcua.sdk.server.OpcUaServer - Eclipse Milo OPC UA Server SDK version: dev
12:34:18.827 [main] INFO  o.e.m.o.s.s.n.OpcUaNamespace - Loaded nodes in 1365ms.
12:34:18.964 [main] INFO  o.e.m.o.sdk.server.NamespaceManager - added namespace index=0, uri=http://opcfoundation.org/UA/
12:34:18.975 [main] INFO  o.e.m.o.sdk.server.NamespaceManager - registered and added namespace index=1, uri=urn:eclipse:milo:examples:server
12:34:18.983 [main] INFO  o.e.m.opcua.sdk.server.OpcUaServer - Binding endpoint opc.tcp://DESKTOP-41IL17I:4840 to localhost [Basic128Rsa15/Sig
nAndEncrypt]
12:34:18.985 [main] INFO  o.e.m.opcua.sdk.server.OpcUaServer - Binding endpoint opc.tcp://DESKTOP-41IL17I:4840 to localhost [Basic256/SignAndE
ncrypt]
12:34:18.985 [main] INFO  o.e.m.opcua.sdk.server.OpcUaServer - Binding endpoint opc.tcp://DESKTOP-41IL17I:4840 to localhost [Basic256Sha256/Si
gnAndEncrypt]
12:34:19.558 [main] INFO  o.e.m.o.sdk.server.NamespaceManager - registered and added namespace index=2, uri=urn:eclipse:milo:hello-world
12:34:20.045 [main] INFO  o.e.m.o.s.s.tcp.UaTcpStackServer - opc.tcp://DESKTOP-41IL17I:4840 bound to localhost:4840 [Basic128Rsa15/SignAndEncr
ypt]
12:34:20.049 [main] INFO  o.e.m.o.s.s.tcp.UaTcpStackServer - opc.tcp://DESKTOP-41IL17I:4840 bound to localhost:4840 [Basic256/SignAndEncrypt]
12:34:20.050 [main] INFO  o.e.m.o.s.s.tcp.UaTcpStackServer - opc.tcp://DESKTOP-41IL17I:4840 bound to localhost:4840 [Basic256Sha256/SignAndEnc
rypt]
12:34:20.050 [main] INFO  o.e.m.o.s.s.tcp.UaTcpStackServer - opc.tcp://DESKTOP-41IL17I:4840/discovery bound to localhost:4840 [None/None]
12:34:20.053 [main] INFO  o.e.m.o.s.s.tcp.UaTcpStackServer - opc.tcp://DESKTOP-41IL17I:4840 bound to localhost:4840 [Basic128Rsa15/SignAndEncr
ypt]
12:34:20.054 [main] INFO  o.e.m.o.s.s.tcp.UaTcpStackServer - opc.tcp://DESKTOP-41IL17I:4840 bound to localhost:4840 [Basic256/SignAndEncrypt]
12:34:20.054 [main] INFO  o.e.m.o.s.s.tcp.UaTcpStackServer - opc.tcp://DESKTOP-41IL17I:4840 bound to localhost:4840 [Basic256Sha256/SignAndEnc
rypt]

编辑服务器0.0.0.0:

20:13:40,090 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
20:13:40,090 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
20:13:40,090 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/C:/Users/Sal/git/repository4
prova2/miloprova2/milo-examples/standalone-examples/target/milo-certificate-server-jar-with-dependencies.jar!/logback.xml]
20:13:40,136 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@3419866c - URL [jar:file:/C:/Users/Sal/git/repository4prova2/milop
rova2/milo-examples/standalone-examples/target/milo-certificate-server-jar-with-dependencies.jar!/logback.xml] is not of type file
20:13:40,226 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
20:13:40,253 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleApp
ender]
20:13:40,256 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
20:13:40,344 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - This appender no longer admits a layout as a sub-component, set an encode
r instead.
20:13:40,344 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
20:13:40,344 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for deta
ils
20:13:40,345 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
20:13:40,345 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
20:13:40,346 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
20:13:40,347 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@63e31ee - Registering current configuration as safe fallback point

20:13:40.627 [main] INFO  o.e.milo.opcua.stack.core.Stack - Successfully removed cryptography restrictions.
20:13:40.632 [main] INFO  o.e.m.e.s.SecureServerStandalone - security temp dir: C:\Users\Sal\git\repository4prova2\miloprova2\milo-examples\st
andalone-examples\target\security
20:13:42.955 [main] INFO  o.e.m.opcua.sdk.server.OpcUaServer - Eclipse Milo OPC UA Stack version: dev
20:13:42.955 [main] INFO  o.e.m.opcua.sdk.server.OpcUaServer - Eclipse Milo OPC UA Server SDK version: dev
20:13:44.710 [main] INFO  o.e.m.o.s.s.n.OpcUaNamespace - Loaded nodes in 1293ms.
20:13:44.824 [main] INFO  o.e.m.o.sdk.server.NamespaceManager - added namespace index=0, uri=http://opcfoundation.org/UA/
20:13:44.837 [main] INFO  o.e.m.o.sdk.server.NamespaceManager - registered and added namespace index=1, uri=urn:eclipse:milo:examples:server
20:13:44.860 [main] INFO  o.e.m.opcua.sdk.server.OpcUaServer - Binding endpoint opc.tcp://DESKTOP-41IL17I:4840 to 0.0.0.0 [Basic128Rsa15/SignA
ndEncrypt]
20:13:44.862 [main] INFO  o.e.m.opcua.sdk.server.OpcUaServer - Binding endpoint opc.tcp://DESKTOP-41IL17I:4840 to 0.0.0.0 [Basic256/SignAndEnc
rypt]
20:13:44.862 [main] INFO  o.e.m.opcua.sdk.server.OpcUaServer - Binding endpoint opc.tcp://DESKTOP-41IL17I:4840 to 0.0.0.0 [Basic256Sha256/Sign
AndEncrypt]
20:13:45.312 [main] INFO  o.e.m.o.sdk.server.NamespaceManager - registered and added namespace index=2, uri=urn:eclipse:milo:hello-world
20:13:45.621 [main] INFO  o.e.m.o.s.s.tcp.UaTcpStackServer - opc.tcp://DESKTOP-41IL17I:4840 bound to 0.0.0.0:4840 [Basic128Rsa15/SignAndEncryp
t]
20:13:45.624 [main] INFO  o.e.m.o.s.s.tcp.UaTcpStackServer - opc.tcp://DESKTOP-41IL17I:4840 bound to 0.0.0.0:4840 [Basic256/SignAndEncrypt]
20:13:45.625 [main] INFO  o.e.m.o.s.s.tcp.UaTcpStackServer - opc.tcp://DESKTOP-41IL17I:4840 bound to 0.0.0.0:4840 [Basic256Sha256/SignAndEncry
pt]
20:13:45.625 [main] INFO  o.e.m.o.s.s.tcp.UaTcpStackServer - opc.tcp://DESKTOP-41IL17I:4840/discovery bound to 0.0.0.0:4840 [None/None]
20:13:45.627 [main] INFO  o.e.m.o.s.s.tcp.UaTcpStackServer - opc.tcp://DESKTOP-41IL17I:4840 bound to 0.0.0.0:4840 [Basic128Rsa15/SignAndEncryp
t]
20:13:45.628 [main] INFO  o.e.m.o.s.s.tcp.UaTcpStackServer - opc.tcp://DESKTOP-41IL17I:4840 bound to 0.0.0.0:4840 [Basic256/SignAndEncrypt]
20:13:45.628 [main] INFO  o.e.m.o.s.s.tcp.UaTcpStackServer - opc.tcp://DESKTOP-41IL17I:4840 bound to 0.0.0.0:4840 [Basic256Sha256/SignAndEncry
pt]

运行客户端;服务器给出此错误:

20:16:27.438 [ua-netty-event-loop-2] ERROR o.e.m.o.s.s.h.UaTcpServerAsymmetricHandler - [remote=/192.168.1.148:12272] Exception caught; sent E
    rrorMessage{error=StatusCode{name=Bad_SecurityChecksFailed, value=0x80130000, quality=bad}, reason=status=Bad_SecurityChecksFailed, descriptio
    n=An error occurred verifying security.}
    io.netty.handler.codec.DecoderException: UaException: status=Bad_SecurityChecksFailed, message=An error occurred verifying security.
            at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:418)
            at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:245)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292)
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:278)
            at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:962)
            at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
            at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528)
            at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:485)
            at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:399)
            at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:371)
            at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
            at java.lang.Thread.run(Unknown Source)
    Caused by: org.eclipse.milo.opcua.stack.core.UaException: status=Bad_SecurityChecksFailed, description=An error occurred verifying security.
            at org.eclipse.milo.opcua.stack.core.util.CertificateValidationUtil.verifyTrustChain(CertificateValidationUtil.java:162)
            at org.eclipse.milo.opcua.stack.core.util.CertificateValidationUtil.verifyTrustChain(CertificateValidationUtil.java:76)
            at org.eclipse.milo.opcua.stack.core.application.DefaultCertificateValidator.verifyTrustChain(DefaultCertificateValidator.java:186)
            at org.eclipse.milo.opcua.stack.server.handlers.UaTcpServerAsymmetricHandler.onOpenSecureChannel(UaTcpServerAsymmetricHandler.java:204
    )
            at org.eclipse.milo.opcua.stack.server.handlers.UaTcpServerAsymmetricHandler.decode(UaTcpServerAsymmetricHandler.java:108)
            at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:387)
            ... 11 common frames omitted

最佳答案

更改OPC服务器地址opc.tcp://localhost:4840更改实际IP机器地址上的'localhost'。

关于java - OPCUA Milo 错误,UaException : status=Bad_ConnectionRejected,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52451319/

相关文章:

java - 当我导出 Java 程序时,为什么出现框架而不出现面板?

java - 在 RecyclerView 中更改单个可绘制对象的颜色将更改所有可绘制对象

java - JNA - 设置资源路径

java - 如何使用 Guava 中的 Splitter.MapSplitter 拆分字符串直到特定键?

java - 从 Public Void 中获取变量 (Android)

java - Eclipse 菜单栏不会显示 - Ubuntu 16.04 - Eclipse Mars

security - Brackets 网站和文本编辑器使用安全吗?

security - 经典 ASP SQL 注入(inject)保护

Python,从内存中删除密码

java - ChromeDriver - 在 Selenium WebDriver 自动化上弹出禁用开发者模式扩展