Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
java.lang.NullPointerException: localApplicationInstanceCertificate is null while connecting to kepserver opc ua from java
February 15, 2024
14:31, EET
Avatar
farhanmemon94
Member
Members
Forum Posts: 6
Member Since:
February 15, 2024
sp_UserOfflineSmall Offline

I am new to OPC UA. I have installed kepserver on my local machine and configured opc ua on kepserver.

I am working on creating java API to read values from opc server on same machine.

When I use MessageSecurityMode.None, it connects and fetches data.

But when I use MessageSecurityMode.SignAndEncrypt, it gives the below exception: –

java.lang.NullPointerException: localApplicationInstanceCertificate is null
at com.prosysopc.ua.stack.transport.security.SecurityConfiguration.(SourceFile:73) ~[prosys-opc-ua-sdk-evaluation-5.0.2-105.jar:na]
at com.prosysopc.ua.stack.transport.tcp.io.TcpConnection.initialize(SourceFile:1276) ~[prosys-opc-ua-sdk-evaluation-5.0.2-105.jar:na]
at com.prosysopc.ua.stack.transport.tcp.io.SecureChannelTcp.initialize(SourceFile:583) ~[prosys-opc-ua-sdk-evaluation-5.0.2-105.jar:na]
at com.prosysopc.ua.stack.transport.tcp.io.SecureChannelTcp.initialize(SourceFile:603) ~[prosys-opc-ua-sdk-evaluation-5.0.2-105.jar:na]
at com.prosysopc.ua.stack.application.Client.createSecureChannel(SourceFile:370) ~[prosys-opc-ua-sdk-evaluation-5.0.2-105.jar:na]
at com.prosysopc.ua.client.UaClient.cgI(SourceFile:5649) ~[prosys-opc-ua-sdk-evaluation-5.0.2-105.jar:na]
at com.prosysopc.ua.client.UaClient.connect(SourceFile:1048) ~[prosys-opc-ua-sdk-evaluation-5.0.2-105.jar:na]
at com.opcua.api.opc.service.OpcUaService.readTag(OpcUaService.java:29) ~[classes/:na]
at com.opcua.api.opc.controller.OpcUaController.getTag(OpcUaController.java:28) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:261) ~[spring-web-6.1.3.jar:6.1.3]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:189) ~[spring-web-6.1.3.jar:6.1.3]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118) ~[spring-webmvc-6.1.3.jar:6.1.3]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:917) ~[spring-webmvc-6.1.3.jar:6.1.3]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:829) ~[spring-webmvc-6.1.3.jar:6.1.3]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-6.1.3.jar:6.1.3]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1089) ~[spring-webmvc-6.1.3.jar:6.1.3]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:979) ~[spring-webmvc-6.1.3.jar:6.1.3]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) ~[spring-webmvc-6.1.3.jar:6.1.3]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:903) ~[spring-webmvc-6.1.3.jar:6.1.3]
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:564) ~[tomcat-embed-core-10.1.18.jar:6.0]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885) ~[spring-webmvc-6.1.3.jar:6.1.3]
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658) ~[tomcat-embed-core-10.1.18.jar:6.0]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) ~[tomcat-embed-websocket-10.1.18.jar:10.1.18]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-6.1.3.jar:6.1.3]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.1.3.jar:6.1.3]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-6.1.3.jar:6.1.3]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.1.3.jar:6.1.3]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-6.1.3.jar:6.1.3]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.1.3.jar:6.1.3]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:340) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-10.1.18.jar:10.1.18]
at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]

February 15, 2024
14:57, EET
Avatar
Matti Siponen
Moderator
Members

Moderators
Forum Posts: 349
Member Since:
February 11, 2020
sp_UserOfflineSmall Offline

Hello,

As the message “localApplicationInstanceCertificate is null” suggests, you apparently have not created an Application Instance Certificate for your Client application. When connecting with security, the Client and the Server applications must exchange and trust each other’s Application Instance Certificates. If your Client application doesn’t have such certificate, it won’t be able to connect using SignAndEncrypt.

Have you perhaps used the SimpleClient sample application as basis for your OPC UA Client application? SimpleClient is a minimalistic Client that doesn’t create an Application Instance Certificate so it can only be used to connect without security.

We would recommend you to check the Client Tutorial bundled with the SDK distribution for an introduction to developing Client applications using the SDK. It is also recommended to take a look at SampleConsoleClient sample application for an example of a Client that supports various features of OPC UA Client-Server communication.

February 18, 2024
13:34, EET
Avatar
farhanmemon94
Member
Members
Forum Posts: 6
Member Since:
February 15, 2024
sp_UserOfflineSmall Offline

Matti Siponen said
Hello,

As the message “localApplicationInstanceCertificate is null” suggests, you apparently have not created an Application Instance Certificate for your Client application. When connecting with security, the Client and the Server applications must exchange and trust each other’s Application Instance Certificates. If your Client application doesn’t have such certificate, it won’t be able to connect using SignAndEncrypt.

Have you perhaps used the SimpleClient sample application as basis for your OPC UA Client application? SimpleClient is a minimalistic Client that doesn’t create an Application Instance Certificate so it can only be used to connect without security.

We would recommend you to check the Client Tutorial bundled with the SDK distribution for an introduction to developing Client applications using the SDK. It is also recommended to take a look at SampleConsoleClient sample application for an example of a Client that supports various features of OPC UA Client-Server communication.  

I had already checked SampleConsoleClient earlier, but this time I went deeper into its certificate validator & security part and I was able to connect the opc ua on kepserver with security and trusting the self-signed certificate. Thanks a lot.

February 19, 2024
11:27, EET
Avatar
farhanmemon94
Member
Members
Forum Posts: 6
Member Since:
February 15, 2024
sp_UserOfflineSmall Offline

Till now, “Allow anonymous login” in kepserver OPC UA properties was set to “Yes” and the connection was successful without any user credentials.

Now, “Allow anonymous login” in kepserver OPC UA properties is set to “No”, so what user credentials should be used to login and how can new user be created for the same?

February 19, 2024
13:05, EET
Avatar
farhanmemon94
Member
Members
Forum Posts: 6
Member Since:
February 15, 2024
sp_UserOfflineSmall Offline

farhanmemon94 said
Till now, “Allow anonymous login” in kepserver OPC UA properties was set to “Yes” and the connection was successful without any user credentials.

Now, “Allow anonymous login” in kepserver OPC UA properties is set to “No”, so what user credentials should be used to login and how can new user be created for the same?  

I was able to create new user. It was under Windows System Tray -> Right click on kepserver icon -> Settings. In Setting dialog box, click on “User Manager” tab and click on “New User” icon.

The credentials of the new user were used to connect and it was successful.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
44 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 726

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala, efrennowell431, wilfredostuart, caitlynfajardo, jeromechubb7, franciscagrimwad, adult_gallery

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0

Administrators: admin: 1